order of execution in Triggers

We are creating validation rules, workflow rules, assignment rules, auto-responsive rules, escalation rules and apex triggers etc..

If the condition is same for all the rules which will execute first and which will execute next, for this salesforce provide the order.



Here is cheat-sheet of Order of execution. Salesforce performs the following events in below order.

  1. Loads Initial record.
  2. If the request came from a standard UI edit page, Salesforce runs system validation to check the record for page layout specific rules, field definition, Maximum field length.
  3. Executes  flows that make before-save update. (New Change in Winter 20)
  4. Executes all before triggers
  5. Runs most Custom validation.
  6. Executes duplicate rules
  7. Saves the record to the database, but doesn’t commit yet. 
  8. Executes all after triggers
  9. Assignment rules
  10. Executes auto-response rules
  11. Executes workflow rules
  12. If there are workflow field updates, updates the record again.
  13. Due to Workflow field updates introduced new duplicate field values, executes duplicate rules again. If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.
  14. Executes processes and flow. 
  15. Escalation rules
  16. Executes entitlement rules
  17. Executes record-triggered flows that are configured to run after the record is saved.
  18. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure. 
  19. If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure. 
  20. Executes Criteria Based Sharing evaluation
  21. Commits all DML operations to the database
  22. Executes all after-commit logic, such as sending email.


Thanks for Reading 

No comments: