Skip to main content
While inserting new account records before update account trigger is firing. I don't want to execute update trigger how to stop these update trigger execution. Please assist me.

Thanks!
5 answers
  1. Sep 4, 2018, 11:15 AM
    Hi Krishna,

    We can use a static variable to prevent code to be executed. As per the order of execution, all Before Trigger and After Trigger will fire before the workflow update. To prevent Trigger to be fired the second time, after workflow field update we can set a static boolean variable in a Class.

    Create a static variable in a class as true. Make it false before or after a trigger has been executed. Variable will become false when trigger runs for the first time (before workflow update). If the variable is true only then trigger will fire and if the trigger will try to execute the second time then it will not fire.

    Handler Class:

    public class TestHandler{

    public static Boolean isTriggerExecuted = true;

    }

    Trigger:

    trigger testTrigger on Account (before update){

    if(TestHandler.isTriggerExecuted){

    //Logic

    TestHandler.isTriggerExecuted = false;

    }

    }

    I hope it helps you.

    Kindly mark this as solved if the information was helpful.

    Regards,

    Khan Anas