Salesforce Order of Execution
Salesforce has a set of rules made on objects and fields. For instance, you can define different rules like validation, workflow, process builder, flows, assignment, hike, auto reply rules etc.
Either you may be an administrator, developer, consultant or architect, it is necessary for you to understand the order of executing the rules. Whenever you save information with an insert, update statement, salesforce online training executes the below events in order.
If the record includes any dependent checklist sections, then the browser compiles JavaScript confirmation before the execution of these action on the server. The confirmation limits every dependent checklist field to its available details. There are no confirmations that occur on the client side.
Execution Order in Salesforce:
- First, the database is filled with Original record or starts the record for an insert or update statement.
- System validation rules:
Updates the new record field data from the request and replaces the old data.
When an invitation came from a standard UI modify page, then Salesforce executes system confirmation to check the report for:
Conformation with layout concerned rules
Necessary values at the interface and field definition level
Approved field patterns
Highest field size
When the invitation comes from other resources, like a SOAP API call or Apex application, Salesforce checks foreign keys only. Salesforce checks if any custom external keys don’t point to the object itself, before completing a trigger action.
When multiline objects like the quote and opportunity line objects are made, Salesforce executes user-defined confirmation guidelines.
- Compiles everything before triggers.
- Custom validation rules:
Except for enforcement of layout specific rules, Again salesforce training executes many system validation steps, like checking all necessary fields that have no-zero data, and any user defined validation rules.
5. Compiles Duplicate Rules:
If the copied rule finds the record as a copied one and uses the block activity, the record won’t save and the next steps like triggers and work process guidelines are not taken.
- Stores the data in the database, but it will not confirm it yet.
- Runs all next to triggers
- Runs assignment rules
- Runs auto-reply rules
- Runs workflow rules
- If we have any work plan updates, the record is updated again
- Once again, the front and back triggers are compiled, when the record is refreshed with updated working rules. But, the thing is custom confirmation, copy and escalation rules are not compiled once again.
- Executing flows and processes are initiated through flow trigger work flow operations. When a process or flow runs a DML operation, then the related record is saved.
- Runs escalation rules
- Runs act rules
- When the record consists of execution review section or is included in any cross-object work process, performs estimations and updates the execution review field in the main record. After that parent record is saved.
- When the parent record is refreshed, and a grandparent record consists of execution review section or is included in a cross-object work process, makes estimations and updates the execution review field in the grandparent record. After that, Grandparent record is saved.
- Runs sharing testing based on some plan.
- Confirms all DML functions to the database.
- Runs after confirmation logics like sending the email.
Important Points:
Pay attention to these things when working with triggers:
When there are multiple triggers to the same object, the execution order is not sure because of the same event. Suppose if there are two frontend insert triggers for the case, and a new case record is kept that starts the two triggers, then the order for these trigger start is not confirmed.
When a DML call is made along with low success allowed, if the first attempt leads to faults for some records, then more than one trial can be made to save the successful records.
If your company uses contacts to different accounts, when you insert a non-private contact or change a contact’s main account, an Account Contact Relation is created and its confirmation rules, database updation, and triggers are executed after saving the contact to the database.
In this article, I have given you about, what is the order of execution in Salesforce. Follow these steps for proper execution.