I have a before update trigger that essentially records upgrades or downgrades when an opportunity gets updated and then logs this change in a new custom object. The concept is pretty simple, for example, if Amount goes up it's an upgrade, etc.
The trigger works fine, except for when an Opportunity goes to 'Closed Won' it creates duplicate log entries in the custom object. It appears that the trigger is executed twice. Ever other change works as expected with a single entry.
Any ideas what's going on?
Attribution to: user91240192094
Possible Suggestion/Solution #1
Take a look at the documentation on Triggers and Order of Execution.
11: If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.
Perhaps there is a workflow rule on Opportunity in your org that is executed when the Stage goes to 'Closed Won`.
Attribution to: Peter Knolle
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33088