Order of execution in Salesforce

order of execution in salesforce

Order of execution in salesforce is used by a salesforce developer to save a record with insert, update or upsert statement by performing a series of events in a definite order. Before order of execution of events on the server, the browser runs Javascript validation to check if the record contains any dependant picklist. The validation limits each dependant picklist field to the available values.

The order of execution is important for a salesforce administrator, consultant or developer to save a record because it adds more functionality to the salesforce platform with the order of execution of multiple events. If an error occurs while performing the order of execution all changes to the database are rolled back and no further events can be executed.

Salesforce execution order is depicted below in details-

  1. Loading the original record from the database.
  2. System validation rules – This is validation enforced by salesforce like number field should not contain alphabets or phone numbers and should be in a valid format. The system validation rules load the new record field values and overwrite the old values. A standard UI edit page validation will check the record for compliance with layout specific rules.
  • Valid field formats
  • Require values at the layout field
  • Maximum field length

When the request is from an Apex application or a SOAP API, validation is done only on the foreign keys. The validation rules of salesforce are user defined if there are multiline items like quote lines or opportunity lines.

3. Execution of before triggers – The before trigger order of execution help to perform a task before a record is inserted, updated or deleted. This is used to validate the record value before saving it on the database.

4. Custom validation rules – These are built within the application by a salesforce developer and are created on visualforce pages. Custom validation rules verify that all the required fields have non null value and run on user defined validation rules. Salesforce does not run the layout specific rules for the second time.

5. Execution of duplicate rules – This takes place when a user views a record with duplicate data or starts creating a duplicate record. Duplicate rules can be customized by adjusting the setting in standard duplicate rules or by creating custom rules. If the record is duplicate and uses the block action, the record cannot be saved and no after triggers or workflow rules are taken.

6. The record is saved to the database but not committed.

7. Execution of after triggers – After triggers are executed to access field values or records after the data has been inserted or updated in the database. After triggers are used after changes have been made in the database and are the main difference between before update and after update trigger in salesforce.

8. Execution of assignment rules – Assignment rules automates the lead generation and support processes of an organization. Lead assignment rules specify how leads are assigned to users or queues. Case assignment rules determine how cases can be assigned to users or queues. A user can trigger assignment rules by using the assignment rule checkbox.

9. Execution of auto response rulesAuto response rules in salesforce helps to send automated email messages to case submissions or leads based on the attributes of the submitted records. Auto response can be created for a self service portal , customer portal, web to case form or an email message.

10. Execution of workflow rulesSalesforce order execution workflow rules allows automating business processes based on particular criteria to test a record. If the criteria are met, workflow action is executed. The actions can occur immediately when a record is created or can be time dependent to evaluate the record.

11. If the record is updated then before and after triggers are fired once more.

12. Execution of escalation rulesEscalation rules in salesforce are used to escalate cases automatically when the criteria of the case match the rule entry. An escalation rule can reassign the case to a user or a queue. It can also send an email notification to the case owner or other recipients. If the record is updated with workflow field updates before update triggers and after update triggers are fired in addition to standard validation. Custom validation rules, duplication rules and escalation rules do not run again.

13. Execution of entitlement rulesEntitlement rules salesforce defines the timelines or the steps that the support agents take to resolve a case. Entitlement helps to verify if the customer is eligible for support with automated steps or milestones. When a flow or process executes a DML operation, the affected record is saved.

14. A roll up summary field will calculate and update values from the parent record. Then the Parent record saved.

15. If the grandparent record contains a roll up summary trigger in salesforce or is part of cross object workflow, then calculations and updates take place in the grandparent record. Grandparent record undergoes the save procedure.

16. Criteria based sharing evaluation is executed.

17. All DML operations are committed to the database.

18. Post commit logic such as sending an email is executed.

Salesforce makes complicated business processes easy with its implementation techniques. A Salesforce developer should carry out the flow of execution in salesforce to maintain the functionality of the salesforce platform. Since the applications are build and hosted on Apex it can be accessed by using a standard interface. Save order of execution in Salesforce is significant in developing scalable applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat