Thursday, November 1, 2018

What is order of execution in Salesforce?

Today we will try to cover the topic order of execution in Salesforce.

When we save a record , the following is the order of execution in Salesforce,

order of execution in salesforce


1)System validation to verify all required fields are supplied.


2)All before trigger.


3)Custom validation again to verify all required fields are supplied.


4)The record is saved but not committed to the database.


5)All after trigger.


6)Assignment rules.


7)Auto response rule.


8)Workflow rules.


If field update occurs through workflow than,

8.1)Before trigger once again.


8.2)After trigger once again.




9)Process builder.

If field update occurs through process builder than,

9.1)Before trigger once again.


9.2)After trigger once again.


10)escalation rules.


11)Commit data to database.

12)Post Logic after committing data to database.


NOTE:

  • To avoid running of trigger multiple times (i.e to avoid recursive trigger) we can make use of static variable.
  • Order of execution is not guaranteed in case of multiple triggers on same object.

No comments:

Post a Comment