What is the Apex Order of Execution when a record is saved?
Suggested answer
The order of execution on record save:
1. Load original record values from database.
2. Override with new values from the save request.
3. Execute system validations (data type, required fields).
4. Execute all before triggers.
5. Run custom validation rules.
6. Check duplicate rules.
7. Save record to database (not yet committed).
8. Execute all after triggers.
9. Execute assignment rules.
10. Execute auto-response rules.
11. Execute workflow rules (field updates trigger re-evaluation of before/after triggers).
12. Execute processes (Process Builder).
13. Execute escalation rules.
14. Roll-up summary recalculation (if applicable).
15. Recalculate criteria-based sharing.
16. Commit to database.
17. Execute post-commit logic (send email, async enqueue). Understanding this order is critical for debugging unexpected behaviour in multi-automation orgs.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.