Activity Forums Salesforce® Discussions Define Recursive Trigger and how to avoid it in Salesforce?

  • Shweta

    Member
    June 12, 2020 at 4:25 pm

    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;
    }
    }

  • Sumit

    Member
    June 15, 2020 at 6:48 am

    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;
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos