function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TryCodingTryCoding 

How to bypass the trigger of a managed package from apex code

hi

 

i have a managed package with an object and before insert trigger on that object in that package

 

now i want to create the object instance from apex code in my org but i can not fulfil trigger criteria.

 

How can i bypaas that trigger and insert an insatance of that object from my apex code

 

please suggest some solution or some cheat. 

 

regards

TryCoding

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I don't think you can bypass triggers in managed packages - presumably because that could break all manner of code elsewhere in the package.

 

What is the problem with the trigger criteria?

All Answers

bob_buzzardbob_buzzard

I don't think you can bypass triggers in managed packages - presumably because that could break all manner of code elsewhere in the package.

 

What is the problem with the trigger criteria?

This was selected as the best answer
TryCodingTryCoding

the trigger does not allow  inserting the object from code

it gives some error like validation failed

and i cant know what validation has failed

however the same object get inserted from ui by clicking a button

how to insert that object from apex code

this is really important for me

one idea i could think was if i could bypass the trigger anyhow

if u have any other solution. please suggest

 

 

bob_buzzardbob_buzzard

You'll need to find out why the validation is failing I'm afraid.  Are you able to view the validation rules for the object in question?  When you create from the UI is there anything special that takes place (e.g. prefilling lookup relationships, choosing record types etc).