function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MaximeMaxime 

Workflow triggered my trigger twice

Hello,

i have a workflow who trigger my trigger twice (trigger on opp, after update). The problem is that oldMap and newMap are identical...

Is there a way to avoid that ?
 
Best Answer chosen by Maxime
ShirishaShirisha (Salesforce Developers) 

Hi Maxime,

Greetings!

Can you please check the below thread for the workaround to avoid trigger to fire twice:

https://salesforce.stackexchange.com/questions/101812/trigger-is-firing-twice-after-update

https://salesforce.stackexchange.com/questions/109/workflow-rule-causing-trigger-to-fire-twice

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

All Answers

ShirishaShirisha (Salesforce Developers) 

Hi Maxime,

Greetings!

Can you please check the below thread for the workaround to avoid trigger to fire twice:

https://salesforce.stackexchange.com/questions/101812/trigger-is-firing-twice-after-update

https://salesforce.stackexchange.com/questions/109/workflow-rule-causing-trigger-to-fire-twice

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

This was selected as the best answer
Maharajan CMaharajan C
Hi,

With the help of boolean we can stop this recurrsion. Please refere the below blogs.

https://help.salesforce.com/articleView?id=000324749&type=1&mode=1
https://www.sfdcpoint.com/salesforce/avoid-recursive-trigger-salesforce/
https://salesforce.stackexchange.com/questions/101812/trigger-is-firing-twice-after-update
https://www.biswajeetsamal.com/blog/avoid-recursive-trigger-calls-in-salesforce/#:~:text=Recursion%20occurs%20when%20same%20code,%E2%80%9Cmaximum%20trigger%20depth%20exceeded%E2%80%9D.

Thanks,
Maharajan.C