| Description | Many Developers face this issue because of recursive trigger, or recursive update trigger. For example in 'after update' trigger, Developer is performing update operation and this lead to recursive call. |
|---|---|
| Resolution | In order to avoid the situation of recursive call, make sure your trigger is getting executed only one time. To do so, 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. Class code : public Class checkRecursive{ private static boolean run = true; public static boolean runOnce(){ if(run){ run=false; return true; }else{ return run; } } } Trigger code : trigger updateTrigger on anyObject(after update) { if(checkRecursive.runOnce()) { //write your code here } } Reference Link: https://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US |
Tuesday, 19 July 2016
How to avoid Recursive trigger
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment