We are creating validation rules, workflow rules, assignment rules, auto-responsive rules, escalation ruels 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.
Order of execution in salesforce:
-
Prepare the record for insert/update operation.
-
It will replace all the old field values with new field values.
If the request is coming form UI all the system validations will execute:
-
DataType
-
Length
-
Required
-
Unique
-
PageLayot level validations
Before triggers:
Custom Validations and again system validation rules will fire (pageLayot level validations won't fire at this point of time).
Record will be saved into the database but doesn't not commit.
After triggers:
-
Assignment rules.
-
Auto-responsive rules.
-
Workflow Rules.
-
Incase of Workflow Rule Field updates again before triggers and after triggers fire one more time. System validation ruels for duplicate chcek.
-
Escalatoin Rules.
-
Rollup-Summary fields will be calculated.
-
Grant parent Rollup-Summary fields will be calculated.
-
Criteria base sharing evaluation.
-
Record will be commited into the database.
-
Post Commit logic (Sending emails).