You need to sign in to do that
Don't have an account?

How does static boolean variable helps in avoiding recursive triggers?
Hi,
I have seen lot of examples in the posts about avoiding recursive triggers,what i wonder why the boolean value is set to '"true" in helper class that handles the trigger events and why the boolean value is set to "false" in trigger.
can someone explain or post some sample code if possible eith comments so that it make sense to me what the boolean value is exactly doing the helper class and in the trigger.
I have seen lot of examples in the posts about avoiding recursive triggers,what i wonder why the boolean value is set to '"true" in helper class that handles the trigger events and why the boolean value is set to "false" in trigger.
can someone explain or post some sample code if possible eith comments so that it make sense to me what the boolean value is exactly doing the helper class and in the trigger.
[1] https://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US)
http://amitsalesforce.blogspot.in/2015/03/how-to-stop-recursive-trigger-in.html
you can create a class with a static Boolean variable with default value true. In the trigger, before executing your code keep a check that the variable is true or not. Once you check make the variable false
Please let us know if this will help you
Thanks
Amit Chaudhary