12 - Order of Execution
(Hint : Execution can restart for few records at few points . For more check : Reference - 166 / U /SDC)
In Salesforce, the order of execution is important as it determines how records are processed and what actions are performed in response to different types of operations (insert, update, delete, etc.). Here’s a summary of the main steps in Salesforce's order of execution:
System Validation Rules: Salesforce verifies that required fields have non-null values and that field formats are valid.
Before Triggers: Executes "before" triggers, which allow you to set or modify values before the record is saved.
System Validation Rules Again: Runs custom validation rules if the record is modified by a before trigger.
Duplicate Rules: Checks for duplicates based on configured duplicate rules.
Save Record (But Not Committed): Saves the record to the database but does not commit.
After Triggers: Executes "after" triggers, which allow for actions based on record values after they have been saved.
Assignment Rules: Runs assignment rules if they are defined (only for leads and cases).
Auto-Response Rules: Executes auto-response rules (only for leads and cases).
Workflow Rules: Evaluates and executes any workflow rules that meet criteria. If workflow rules modify fields, before and after triggers are re-evaluated.
Processes: Executes process builder flows, which may update fields or trigger other actions.
Escalation Rules: Escalates cases if any escalation rules are configured.
Entitlement Rules: Applies any entitlement rules if configured (only for cases).
Roll-Up Summary Fields: Updates roll-up summary fields if the current record impacts any roll-ups.
Parent Roll-Up Summary Fields: Updates roll-up summary fields on parent records if needed.
Criteria-Based Sharing: Evaluates and applies criteria-based sharing rules.
Commit: Finally, Salesforce commits the record to the database.
Post-Commit Logic:
- After Commit Actions: Executes actions that require a committed record, such as sending emails, firing platform events, and performing post-commit operations.
Understanding these steps is crucial for preventing recursion and managing performance when developing in Salesforce.
Comments
Post a Comment