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

Recursive Trigger
Hi Folks,
There is a after update trigger on account object. In trigger, there is a date field we are checking the date is changed or not if it is changed we are doing some process.
The trigger is executed 5 times in the transaction.
First time debugs:
Old value --- 11/25/2015
New value --- 11/26/2015 dates are different then class is executed.
Second time:
Old value --- 11/26/2015
New value --- 11/26/2015
Third time:
Old value --- 11/25/2015
New value --- 11/26/2015 -- dates are changed then class is executed. but in the second transaction the new date is override the old date but the third time getting different values same as first transaction values. Is it recursive or some thing wrong in the code? There is no field update and not assiging in the code for the field but the update is happened from the Job.
Fourth time:
Old value --- 11/26/2015
New value --- 11/26/2015
Fiftth time:
Old value --- 11/26/2015
New value --- 11/26/2015
Please help on this.
Thanks,
Krish
There is a after update trigger on account object. In trigger, there is a date field we are checking the date is changed or not if it is changed we are doing some process.
The trigger is executed 5 times in the transaction.
First time debugs:
Old value --- 11/25/2015
New value --- 11/26/2015 dates are different then class is executed.
Second time:
Old value --- 11/26/2015
New value --- 11/26/2015
Third time:
Old value --- 11/25/2015
New value --- 11/26/2015 -- dates are changed then class is executed. but in the second transaction the new date is override the old date but the third time getting different values same as first transaction values. Is it recursive or some thing wrong in the code? There is no field update and not assiging in the code for the field but the update is happened from the Job.
Fourth time:
Old value --- 11/26/2015
New value --- 11/26/2015
Fiftth time:
Old value --- 11/26/2015
New value --- 11/26/2015
Please help on this.
Thanks,
Krish
Can you post your trigger code?
Thanks,
Krish
http://amitsalesforce.blogspot.in/2015/03/how-to-stop-recursive-trigger-in.html
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.
Apex Class with Static Variable Trigger Code
Belwo is the article which is really good to handle recursive trigger.
https://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US)
Thanks
Manoj
Thanks for your suggestions. I know how to stop the execution second time, but if we see thtat in the third execution of the trigger we are getting the first execution values(actual values). Is it standard behaviour of the salesforce for recursive trigger?
Thanks,
Krish