Activity Forums Salesforce® Discussions How we can Recursive trigger in salesforce?

  • Suraj

    Member
    April 11, 2017 at 1:03 pm

    Hi Saurabh,

    You can use a method which returns a Boolean to check whether the trigger is running first or again (recursive).

    trigger updateTrigger on anyObject(after update) {

    if(checkRecursive.runOnce())
    {
    //write your code here
    }

    }

    runOnce is the method inside CheckRecursive Class which return Boolean.

    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