12 - Order of Execution

Order 

(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:

  1. System Validation Rules: Salesforce verifies that required fields have non-null values and that field formats are valid.

  2. Before Triggers: Executes "before" triggers, which allow you to set or modify values before the record is saved.

  3. System Validation Rules Again: Runs custom validation rules if the record is modified by a before trigger.

  4. Duplicate Rules: Checks for duplicates based on configured duplicate rules.

  5. Save Record (But Not Committed): Saves the record to the database but does not commit.

  6. After Triggers: Executes "after" triggers, which allow for actions based on record values after they have been saved.

  7. Assignment Rules: Runs assignment rules if they are defined (only for leads and cases).

  8. Auto-Response Rules: Executes auto-response rules (only for leads and cases).

  9. Workflow Rules: Evaluates and executes any workflow rules that meet criteria. If workflow rules modify fields, before and after triggers are re-evaluated.

  10. Processes: Executes process builder flows, which may update fields or trigger other actions.

  11. Escalation Rules: Escalates cases if any escalation rules are configured.

  12. Entitlement Rules: Applies any entitlement rules if configured (only for cases).

  13. Roll-Up Summary Fields: Updates roll-up summary fields if the current record impacts any roll-ups.

  14. Parent Roll-Up Summary Fields: Updates roll-up summary fields on parent records if needed.

  15. Criteria-Based Sharing: Evaluates and applies criteria-based sharing rules.

  16. Commit: Finally, Salesforce commits the record to the database.

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

Popular posts from this blog

API Names in Salesforce

18 - LWC - BEST PRACTICES - For accessing HTML elements and their values in JavaScript

6 - Object Relationships (Lookup and Master-Detail and Junction Objects)