You need to sign in to do that
Don't have an account?
Bhushan Singh 13
I have two object and each object contains trigger for recursive execution , how to prevent recursive without using Boolean variable
Hi,
I have two object and each object contains trigger for recursive execution
for e.g. Account has field amount and Contact has also field amount, Both has trigger,
Trigger on Account if amount field will be update that time contact amount field should be update and
Trigger on Contact If amount field of Contact updating that time amount field of Account should be update. SO It is a Recursive trigger, How to prevent this recursive without usin any static boolean variable.
Please help me .
I have two object and each object contains trigger for recursive execution
for e.g. Account has field amount and Contact has also field amount, Both has trigger,
Trigger on Account if amount field will be update that time contact amount field should be update and
Trigger on Contact If amount field of Contact updating that time amount field of Account should be update. SO It is a Recursive trigger, How to prevent this recursive without usin any static boolean variable.
Please help me .
1) http://salesforce.stackexchange.com/questions/46790/how-to-avoid-recursive-trigger-other-than-the-classic-class-w-static-variable
Your trigger should only be firing on very specific criteria. Make them as specific as possible by comparing old and new field values to make sure your criteria is met.
For example if you wanted to only fire when a contacts BirthDate changed then you could do the following: Even though the trigger is updating the current Contact, we don't need to worry about recursion because:
- The trigger will only fire on updates due to the Trigger.isUpdate check
- The trigger will only fire when the Birthdate is changed.
NOTE:- other then static method use new Map and Old MapLet us know if this will help you
All Answers
1) http://salesforce.stackexchange.com/questions/46790/how-to-avoid-recursive-trigger-other-than-the-classic-class-w-static-variable
Your trigger should only be firing on very specific criteria. Make them as specific as possible by comparing old and new field values to make sure your criteria is met.
For example if you wanted to only fire when a contacts BirthDate changed then you could do the following: Even though the trigger is updating the current Contact, we don't need to worry about recursion because:
- The trigger will only fire on updates due to the Trigger.isUpdate check
- The trigger will only fire when the Birthdate is changed.
NOTE:- other then static method use new Map and Old MapLet us know if this will help you
It is working for me .
Thanks
Bhushan