• #69360
    Salesforce | Shubham Shubham #21
    Forcetalks

    How to avoid recursive trigger in Salesforce?

    How to avoid recursive trigger in Salesforce?

    #69362
    Salesforce | Kirandeep Kirandeep #12
    Forcetalks

    Hi Shubham,

    To avoid recursive triggers 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

    #69375
    Salesforce | Arun Arun Pal #14
    Forcetalks

    Hi Shubham,

    Recursion occurs when same code is executed again and again. It can lead to infinite loop and which can result to governor limit sometime. Sometime it can also result in unexpected output or the error “maximum trigger depth exceeded”. So, we should write code in such a way that it does not result to recursion.

    To avoid the situation of recursive call, we have to write code in such a way that the trigger will execute one time. To do so, we can create a class with a static Boolean variable with default value true. In the trigger, before executing the code keep a check that the variable is true or not.

Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.

Popular Salesforce Blogs

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2020 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?