Print this page

Opportunity Workflow fired twice unexpectedly

Knowledge Article Number 000006235
Description

Scenario: Customer reports that an opportunity workflow rule is incorrectly triggered a second time when the price book on the opportunity is changed, despite the fact that the workflow already fired once and the evaluation criteria is set to "When a record is created, or when a record is edited and did not previously meet the rule criteria".

Explanation: In general, most standard objects have what we call “re-parentable foreign keys”. In this case, the foreign key is the price book lookup on the opportunity (the physical act of clicking the 'Choose Price Book' button). If you change the foreign key on a record, we fire the workflow rules all over again as we treat this as a new record. You can see this same behavior with contact and case workflow rules when you change the parent account or contact on a case. The same also occurs when changing the "account name" value on Opportunity and in various other situations.


Workflow rules are triggered when a standard object in a master-detail relationship is re-parented, even if the object's evaluation criteria is set to When a record is created, or when a record is edited and did not previously meet the rule criteria.

So, essentially, what is happening is that the rule fires once when the opportunity is saved but prior to clicking the 'Choose Price Book' button and then fires again once the price book is selected (foreign key change on the opportunity).

Resolution

The workaround which has been implemented by many customers is as follows:

1. Create a checkbox ("OppWorkflowGatekeeper") that is hidden from all users at the page layout level (in other words, not on the page layout)
2. Add a line of criteria to the workflow rules which currently have this issue that is: "OppWorkflowGatekeeper" | Equals | False
3. Add a field update action to the workflow rule which currently has this issue which updates the "OppWorkflowGatekeeper" to True

What will happen is that after the rule is triggered the first time (when the opportunity is saved but prior to clicking the 'Choose Price Book' button and when the "OppWorkflowGatekeeper" = False), the workflow field update will update the "OppWorkflowGatekeeper" to True and then when the user clicks the 'Choose Price Book' button, the "OppWorkflowGatekeeper" will be True and therefore the criteria of the workflow will evaluate to False and the workflow will not fire a second time and the duplicate emails will not be sent.


Note:

1) If there are multiple workflow rule on opportunity then a gatekeeper field needs to be created for each workflow to address the issue
2) Similar resolution can be applied to opportunity product too

 





promote demote