Order of execution in Salesforce

1. System Validation Rules.

2. Executes all before triggers.

3. Custom Validation rules.

4. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses the block action, the record is not saved and no further steps, such as after triggers and workflow rules, are taken.

5. Saves the record to the database, but doesn't commit yet.

6. Executes all after triggers.

7. Executes assignment rules.

8. Executes auto-response rules.

9.Executes workflow rules.

10.  If there are workflow field updates, updates the record again.

11.  If the record was updated with the workflow field update, it fires before and after triggers one more time (and only one more time) with standard validation rules. Custom validation rules, duplicate rules, and escalation rules are not run again.

Note:
If there were multiple field updates which updated the record, before and after triggers with standard validation rules will be fired only one time.

12. Executes processes and flows launched via processes and flow trigger workflow actions. When a process or flow executes a DML operation, the affected record goes through the save procedure.

13. Executes escalation rules.

14. Executes Entitlement Rules.

15. If the parent record is updated, and a grand-parent 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. Grand-parent record goes through save procedure.

16. 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.

17. Executes Criteria Based Sharing evaluation.

18. Commits all DML operations to the database.

19. Executes post-commit logic, such as sending email.

5 comments:

  1. Thank you very much for the info.

    ReplyDelete
  2. how many times workflow field update will be called in triggers

    ReplyDelete
    Replies
    1. Depends upon the re-evaluate check box. The Re-evaluate should not cause recursive issue.

      Delete
  3. Very simple and lucid note and very easy to grab. Thanks

    ReplyDelete