Order of execution in salesforce

 

Order of execution in salesforce is like an ABC in Salesforce World!

1. System Validation rule (required field, field format).
2. Before Triggers are executed .
3. Custom Validation rules are checked.
4. After Triggers are executed.
5. Assignment Rules are executed .
6. Auto-Response Rules are executed.
7. Workflow Rules are executed.
8. Before and after triggers are executed one more time if the workflow rule updates a field.
9. Escalation Rules are executed.
10. Parent Rollup Summary Formula or Cross Object Formula fields are updated in the respective objects.
11. Criteria Based Sharing rules are evaluated.
12. Any Post-Commit Logic is executed.

 

Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.html