You need to sign in to do that
Don't have an account?

Maximum trigger depth exceeded - Account Trigger/Opportunity Trigger
I am getting maximum trigger dept exceeded error, because (1) Account After update trigger is updating opportunities (used in SF2SF updates) (2) Opportunity After Update trigger is updating account information (internal sales process)
I used to have #2 scenario in workflow rules, that I have to move to trigger due to WF rule limit. I am using static variable but I am still getting this error. How can I identify/differentiate #1 and #2 scenario in Trigger and prevent this recursive calling. Any suggestions?
I used to have #2 scenario in workflow rules, that I have to move to trigger due to WF rule limit. I am using static variable but I am still getting this error. How can I identify/differentiate #1 and #2 scenario in Trigger and prevent this recursive calling. Any suggestions?
For long term, it is better to adopt a trigger handler framework. Here is a nice article on the topic: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
All Answers
For long term, it is better to adopt a trigger handler framework. Here is a nice article on the topic: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
You can easily find some examples online if unsure.
1) http://amitsalesforce.blogspot.in/2015/03/how-to-stop-recursive-trigger-in.html
Apex Class with Static Variable
public class ContactTriggerHandler {
public static Boolean isFirstTime = true;
}
Trigger Code
trigger ContactTriggers on Contact (after update)
{
Set<String> accIdSet = new Set<String>();
if(ContactTriggerHandler.isFirstTime)
{
ContactTriggerHandler.isFirstTime = false;
for(Contact conObj : Trigger.New)
{
if(conObj.name != 'Test') { accIdSet.add(conObj.accountId); }
} // any code here
}
}
Let us know if this will help you