PDI · Question #122
A developer writes a trigger on the Account object on the before update event that increments a count field. A workflow rule also increments the count field every time that an Account is created or…
The correct answer is D. 2. When an Account is inserted, a workflow rule's field update can trigger a recursive save, causing before update triggers to execute.
Question
A developer writes a trigger on the Account object on the before update event that increments a count field. A workflow rule also increments the count field every time that an Account is created or updated. The field update in the workflow rule is configured to not re-evaluate workflow rules. What is the value of the count field if an Account is inserted with an initial value of zero, assuming no other automation logic is implemented on the Account?
Options
- A1
- B3
- C4
- D2
How the community answered
(57 responses)- A4% (2)
- B7% (4)
- C18% (10)
- D72% (41)
Why each option
When an Account is inserted, a workflow rule's field update can trigger a recursive save, causing `before update` triggers to execute.
This value would occur if only one automation (either the workflow or the trigger) ran, or if the recursive save did not activate the `before update` trigger.
This value would require additional increments beyond the described workflow and trigger execution in the standard order of operations.
This value would require multiple additional increments, suggesting a different order of execution or additional automation not mentioned.
An Account inserted with count=0 first triggers the workflow rule, setting count to 1. This field update initiates a recursive save, causing the `before update` trigger to fire and increment the count again to 2. The workflow rule's 'do not re-evaluate' setting prevents a second workflow execution.
Concept tested: Salesforce Order of Execution (DML, triggers, workflow)
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
Topics
Community Discussion
No community discussion yet for this question.