Order of execution in Salesforce

 Here is Order of execution. Salesforce performs the following events in below order.


    Loads Initial record.
    If the request came from a standard UI edit page, Salesforce runs system validation to check the record for page layout specific rules, field definition, Maximum field length.
    Executes  flows that make before-save update. (New Change in Winter 20)
    Executes all before triggers. 
    Runs most Custom validation.
    Executes duplicate rules. 
    Saves the record to the database, but doesn’t commit yet. 
    Executes all after triggers. 
    Assignment rules. 
    Executes auto-response rules. 
    Executes workflow rules. 
    If there are workflow field updates, updates the record again.
    Due to Workflow field updates introduced new duplicate field values, executes duplicate rules again. If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.
    Executes processes and flow. 
    Escalation rules. 
    Executes entitlement rules. 
    Executes record-triggered flows that are configured to run after the record is saved.
    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. Parent record goes through save procedure. 
    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. Grandparent record goes through save procedure. 
    Executes Criteria Based Sharing evaluation. 
    Commits all DML operations to the database. 
    Executes all after-commit logic, such as sending email.

Comments

Popular posts from this blog

Upload/Create/Send attechments/file to Google Drive from Apex Salesforce (Using Salesforce Google Drive Integration)

What is Apex Triggers.? Why we Use? What is Syntex? What is Events? What is Context Variable? What is bulkify triggers?

OAuth 2.0 JWT Bearer Flow for Server-to-Server Integration