Recursion occurs when the same code is executed again and again. Due to this, an error is populated maximum trigger depth is exceeded.
We can stop this by creating a static variable. With this variable trigger, code execute one time.
Apex Trigger:
trigger ContactTrigger on Conatct(before insert) {
if(ContactTriggerHelper.runOnce){
ContactTriggerHelper.runOnce = false;
// trigger logic
}
}
Apex Helper Class:
public class ContactTriggerHelper {
public static boolean runOnce = true;
}
What’s your Reaction?
+1
1
+1
+1
+1
+1
+1
4 comments
It’s fantastic that you are getting thoughts from this paragraph as well as from our dialogue
made at this place.
Thanks for feedback 😊
how can we stop the recursion in record triggered flow ??
Hi @Praveen,
There is a radio field on record trigger flow show you can select 2nd one and also put strong entry criteria.