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

  • Marziya

    Member
    May 26, 2020 at 1:05 pm

    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.

  • Shweta

    Member
    May 26, 2020 at 1:41 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;
    }
    }

  • Pooja

    Member
    May 26, 2020 at 1:59 pm

    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.

Popular Salesforce Blogs

Popular Salesforce Videos