Activity Forums Salesforce® Discussions How Recursive Trigger Handling in Salesforce can be done for Upsert Operation?

  • shariq

    Member
    September 24, 2018 at 4:58 am

    Hi,

    You can avoid recursive trigger in salesforce using static variable.

    You can also create a boolean variable in custom setting and toggle it with your logic

    Hope this helps.

  • Avnish Yadav

    Member
    September 24, 2018 at 1:09 pm

    Hello,

    public class RecursiveTriggerHandler{
         public static Boolean isFirstTime = true;
    }

    ------------------------------------------------------------

    trigger SampleTrigger on Contact (after update){
     
        Set accIdSet = new Set();
         
        if(RecursiveTriggerHandler.isFirstTime){
            RecursiveTriggerHandler.isFirstTime = false;
             
            // Calling Apex Class with Logic
        }
    }

    Hope this will you.

    Thanks.

  • Parul

    Member
    September 28, 2018 at 8:41 pm

    You can avoid recursive trigger in salesforce using static variable.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos