Order of Execution – Salesforce

Salesforce-order-of-execution.png

1) Loads the  record from the database or initializes the record for an upsert statement.
2) Loads the new record field values from the request and overwrites the old values with new values.

If the request came from a standard User Interface edit page,  runs system validation to check the record for:
-Checks whether Required values is present or not at the page layout level and field-definition level
-Checks field formats are valid or not (example:  Email ID format, Phone number format)
3) All before triggers execution.
4) Runs most system validation steps again, such as verifying that all required fields have a non-null value, and then runs any custom validation rules. The only system validation that Salesforce doesn’t run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.
5) Saves the record to the database, but doesn’t commit yet to Database.
6) all after triggers Executed.

7) Run assignment rules and auto-response rules.
8) workflow rules Executed.
9) If there is any workflow field update, updates the record again.
10) If the record  updated with workflow field update, fires before and after triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.
11) escalation rules executed.
12) If the record contains a roll-up summary field, rollup summary fields are calculated and updated.
13) Run Criteria Based Sharing evaluation.
14) Commits all DML operations to the database.
15) Run post-commit logic, such as sending email.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s