How to avoid recursive trigger in salesforce

image


How do I restrict a recursive trigger in Salesforce?

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.


How do you handle a recursive trigger?

Handle recursion – To avoid the recursion on a trigger, make sure your trigger is getting executed only one time. You may encounter the error : ‘Maximum trigger depth exceeded’, if recursion is not handled well.


How do I stop a recursive workflow in Salesforce?

For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive workflow rules. If you don’t enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.


How do I stop an infinite loop in Salesforce?

Use Trigger Filters to Prevent Infinite Loops By filtering out these Salesforce contacts, the contact will be ignored by the recipe and will not cause an infinite loop.


What are the best practices for triggers in Salesforce?

Best Practice to Follow while writing trigger One Trigger Per Object. … Logic-less Triggers. … Context-Specific Handler Methods. … Bulkify your Code. … Avoid using DML statements and SOQL Queries inside FOR Loops. … Using Collections, Streamlining Queries, and Efficient For Loops. … Querying Large Data Sets.More items…•


What is trigger recursion in Salesforce?

Triggers allow modification of another record of the same type or different type. Recursion is the process of executing the same task multiple times. The Recursive trigger is a trigger which calls itself repeatedly and leads to an infinite loop. There may be chances to hit the Governor Limit with Recursive Trigger.


How do you avoid recursion in a workflow?

For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive workflow rules. If you don’t enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.


How can recursion flow be prevented?

If you don’t have it just create a new Boolean field , and update it accordingly on your flow when you don’t want the other flows from firing and just do the process previously mentioned using that field as your criteria to finish the flow prematurely.


What is re evaluate workflow rules after field change?

If “Re-evaluate Workflow Rules after Field Change” is enabled for a field update action then Salesforce re-evaluates all workflow rules on the object if the field update results in a change to the value of the field. Only workflow rules that didn’t fire before will be retriggered.

Leave a Comment