You need to sign in to do that
Don't have an account?
To prevent trigger from firing if it is called from one class
Hi,
I have trigger called "OpportunityChange" this will be fired if there is any change (insert/update/delete) on Oportunity Object.
I have lot of ther clases which does insert/update/delete operations on Opportunity object. I want to stop the trigger "OpportunityChange" from being fired if it is called from a class "OpportunityEquipment" but it needs it be fired if it is called from other classes.
Please let me know how to achieve this. (I am ready to change the class "OpportunityEquipment" and "opportunitychange" trigger only to get this functionality but other classes which calls the trigger shouldnot be changed).
Thanks,
JBabu.
Create a class:
in your class call recursionCheck.stopRecursion();
in your trigger, wrap the contents in and if(recursionCheck.canIRun()){}
All Answers
If it is a method call you can overload the method and call the overloaded method from the class.
But since it is a trigger, this is what I could think of....
It would be good if you have a data point (say a text field) that specifies some indication that this record is inserted/updated from a class.
When you are inserting/updating a record from the class you can specify desired value to the field.
Then in trigger you can add a if condition to check the data point for specific value and just exit without going further.
Dont forget to change the data point value back to blank so it is not skipped when it is updated from other classes.
Create a class:
in your class call recursionCheck.stopRecursion();
in your trigger, wrap the contents in and if(recursionCheck.canIRun()){}
Thanks a lot Starz and Krish.
@starz26 Thanks for your answer, but the boolean should be static also.