Activity Forums Salesforce® Discussions How to avoid Recursive Trigger in Salesforce ?

  • Shweta

    Member
    January 22, 2020 at 3:07 pm

    Recursion occurs when same code is executed again and again. you can avoid it by using Static Boolean variable.

    To avoid the recursion on trigger make sure your trigger is getting executed only one time.

    Example :  you have to create a class with a static boolean variable with default value true and once you check make the variable false.

    Public class check{
    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