Activity Forums Salesforce® Discussions How to avoid recursive trigger calls in Salesforce?

  • How to avoid recursive trigger calls in Salesforce?

  • Manpreet

    April 18, 2017 at 1:37 pm

    Ineed to stop the recursive behaviour of trigger calls?

  • Suraj

    April 18, 2017 at 1:45 pm

    Hi Manpreet,

    In order to avoid the situation of recursive call, make sure your trigger is getting executed only one time. To do so, 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.


  • Avnish Yadav

    September 30, 2018 at 3:51 am

    Here is the code-

    Apex class:-

    public Class checkRecursive {
        private static boolean run = true;
        public static boolean runOnce(){
                return true;
            } else{
                return run;

    Trigger -

    trigger updateTrigger on anyObject(after update) {
            //write your code here


Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos