Salesforce Certified Platform Administrator II free question 9 / 10 · Domain 7: Process Automation
Opportunity has a validation rule that blocks saving when the discount exceeds 30%. A workflow rule has a field update that rewrites the discount of opportunities meeting its criteria to 35%. A sales rep saves an opportunity that meets the rule's criteria, entering a discount of 20%. Which outcome matches the order of execution in the Apex Developer Guide (Summer ’22)?
- The field update runs before the validation rule, so the validation rule checks the rewritten 35% and the save is blocked
- The validation rule also runs after the field update's re-save, the 35% breaks the rule, and the rep's whole save fails with an error
- The validation rule also runs after the field update's re-save, the field update is undone, and the opportunity is saved at 20%
- The validation rule doesn't run again after the field update's re-save, so the opportunity is saved at 35%
Show the answer and explanation
Answer: D
Why this is correct
"Triggers and Order of Execution" says that when a workflow rule has field updates, the record is updated again and system validation is run again, but custom validation rules, flows, duplicate rules, processes, and escalation rules are not run again. The validation rule was evaluated and passed at the original save, with the discount at 20%. It doesn't run after the field update's re-save, so the opportunity is saved at 35%.
Why the other options are wrong
"The validation rule also runs after the field update's re-save, the 35% breaks the rule, and the rep's whole save fails with an error" … The guide says custom validation rules are not run again after a workflow field update. The 35% isn't checked, so the save doesn't fail.
"The validation rule also runs after the field update's re-save, the field update is undone, and the opportunity is saved at 20%" … Because the validation rule doesn't run after the field update's re-save, nothing breaks a rule and nothing causes the field update to be undone. The value is saved as 35%.
"The field update runs before the validation rule, so the validation rule checks the rewritten 35% and the save is blocked" … In the guide's order, custom validation rules run before the record is saved (after the before triggers), while workflow rules and their field updates run after the save and after triggers. The field update comes after the validation rule, and the rule isn't run again.
Key point
After a field update, the before update and after update triggers run once more, along with system validation. The ceiling your validation rule protects can be exceeded by a workflow field update, so design the values a field update writes to follow the same conditions as the validation rule.