Activity › Forums › Salesforce® Discussions › Define Recursive Trigger and how to avoid it?
-
Define Recursive Trigger and how to avoid it?
Posted by Sumit kumar on May 26, 2020 at 12:54 PMDefine Recursive Trigger and how to avoid it?
Pooja replied 6 years ago 4 Members · 3 Replies -
3 Replies
-
To avoid recursive triggers 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.
- [adinserter block='9']
-
Recursive Trigger: If a trigger is called again and again than it is called a recursive trigger.
To avoid recursive triggers we can create a class with a static Boolean variable with default value true. e.g.
public Class checkRecursive{
private static boolean run = true;
public static boolean runOnce(){
if(run){
run=false;
return true;
}else{
return run;
}
} -
A trigger is called again and again than it is called a recursive trigger.
To avoid recursive triggers we can create a class with a static Boolean variable with default value true.
Log In to reply.