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
Nihar Annamaneni 7Nihar Annamaneni 7 

Users report multiple intermittent errors and unexpected results when saving a record. Upon investigation, the developer finds that trigger are executing more than one. What is a potential solution to solve this situation?

 Users report multiple intermittent errors and unexpected results when saving a record. Upon investigation, the developer finds that trigger are executing more than one. What is a potential solution to solve this situation?
a)    Use a one trigger per object approach
b)    Use a static variable to check if the trigger has already run.
c)    Disable all triggers and use workflow rule…..
d)    Use private
Narender Singh(Nads)Narender Singh(Nads)
Hi,
My suggestion would be disable all the triggers and try to achieve the required functionality using a workflow. Writing an apex code comes with a lot of considerations. Writing Apex should be your last resort to achieve a particular scenario.
Another great and very powerful UI tool is process builder.
Difference between a workflow and process builder is that Workflows can't do cross object update where as on the other hand, process builder is very much capable of doing that.

If the process builder fails to achieve the required functionality only then you go for writing custom code.
The options which you gave:
Use a one trigger per object approach,
 Use a static variable to check if the trigger has already run,
 Use private

All these 3 could be a potential solution for your problem depending upon on trigger.

Let me know if that helps.
Thanks! 
Rahul Garg SFDRahul Garg SFD
Answer B (Use a static variable to check if the trigger has already run) seems correct.

As the problem of  "trigger are executing more than one" can be solved by using static variable.