Development questions

What is the exact Order of Execution in Salesforce when a record is saved?

Simplified order for a record save:

  1. Load original record (or initialize for insert)
  2. Overwrite with new values; run system validation
  3. Run before-save record-triggered flows
  4. Run before triggers
  5. Run most system validation again, then custom validation rules
  6. Run duplicate rules
  7. Save record to the database (not committed)
  8. Run after triggers
  9. Run assignment rules, auto-response rules
  10. Run workflow rules (field updates can re-fire before/after update triggers once)
  11. Run escalation rules, after-save record-triggered flows
  12. Run entitlement rules
  13. Roll-up summary / cross-object formula recalculation on parents
  14. Criteria-based sharing evaluation
  15. Commit to the database
  16. Post-commit: email, async work (future, queueable), platform events

Knowing this helps debug conflicts between flows, validations and triggers.

apex-triggertriggerorder-of-execution