Order of Execution in Salesforce

Hi Folks,

Very happy to meet you all with this useful info. If you are fresh to Salesforce, this post is for you guys. If you are well-versed in Salesforce, this post will helps you to refresh the things which you already know :P

Here, I am going to share about Order of Execution in Salesforce. When we create/update a record, so many actions will take part of it. Lets list out the executions in order.

1) Loads the original record from DB(update) or initialize the record (Insert).

2) Loads the new record field values and overwrite the old values.

3) If you are using Standard UI, Standard validations will take part now.

For instance - Valid field format, Maximum length of the field and etc...

4) Executes all Before triggers.

5) Executes all Custom validations.

6) Executes Duplicate Rules.

7) Saves the record to the database, but does not commit yet.

8) Executes all After trigger.

9) Executes Assignment Rules.

10) Executes Auto-Response Rules.

11) Executes our favouirt Workflow Rules.

12) If there are any workflow updates, update the record again.

13) If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (only one more time), in addition to standard validations. Custom validation rules and duplicate rules are not run again.

14) Executes Processes.

15) Executes Escalation Rules.

16) Executes Entitlement Rules.

17) 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. 

18) 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. 

19) Executes Criteria Based Sharing evaluation.

20) Commits all DML operations to the database.

21) Executes post-commit logic. For instances - Sending.

 

Let me know your thoughts in comment.

Happy Coding :)

 

Tags: 
Rating: 
No votes yet