I have some very simple automation in place for demoing Salesforce "Order of Execution". I have a field on called Version__c which increments by 1 in a trigger and a workflow. This is what happens:
- Before update trigger fires, Version__c increases to 1
- Workflow w/ field update fires, Version__c increases to 2
- Before update trigger fires again, Version__c increases to 3
I'm hoping to add more even more automation to this (process builder) and have our team easily track these types of changes when something unexpected in our org occurs.
The best visualization tool that I could come up with was in the Developer Console.
Debug > Perspective Manager > change to All (Predefined) > Click Save Order or Timeline tab
Are there any other tips/tricks that I could share to our non technical team members to help investigate these types of scenarios? I'll be honest, I even find Salesforce's developer console a bit verbose and intimidating at times…
****Update – I added a process builder (with Recursion unchecked), which increments the Version even more.****
My debug in the trigger appears hit 3 times in the logs. But the output is now 5? Now I'm even confused as to what is happening behind the scenes…
- Process Builder runs, updates the Version__c to 4?
- Trigger runs again, updates the Version__c to 5?
Best Answer
After researching this extensively I didn't find any other good tools for determining the order of how these fire. What really is unfortunate is how unreliable this really is for the following reasons:
For what it's worth here is the output and how many times each automation metadata type runs (in their respective order):
workflow and trigger (2): Trigger Ran; Workflow Ran; Trigger Ran;
workflow and process builder (2): Workflow Ran; Process Builder Ran;
trigger and process builder (3): Trigger Ran; Process Builder Ran; Trigger Ran;
all three (5): Trigger Ran; Workflow Ran; Trigger Ran; Process Builder Ran; Trigger Ran;