Set Trigger Order on Flows

While finding the Spring 22 pre-release treasure hunt. I found the “Trigger Flow”. Biggest problem with Flow was to control the order of execution. Now we can set Trigger Order on flows to control the order of execution of the record triggered flows.

Set Trigger Order on Flows

With “Trigger Order” option we can set the order of execution of record trigger flow. This is also another great feature after Flow Trigger Explorer in Spring’22. While saving the Flow you can set the Trigger Order number field to set the order. As per tool tips. You can enter a number from 1 to 2000 to prioritize the order that the flow triggers run for a specified object. The Trigger order value determines the order that flows with the same object.

For Example, you can prioritize an after save flow to run before other after save flows on Case Object. But you can’t prioritize an after save flow to run before any before save flows or before an Apex trigger.

Last time, we talk about “One Flow per object per context” rule to control the order of execution in record Trigger flow base on Apex Trigger Framework. Now question is that we really need One Record Triggered Flow Per Object Per Type flow design pattern?

Summary

Now it makes a lot of sense to go with “multiple flows per object” as you can control order of record trigger flow order by set Trigger order on flow? It might be to really please share your thought in comment. Don’t forget to tell us your favorite feature of Spring’22.

Amit Chaudhary
Amit Chaudhary

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.

He is a active blogger and founder of Apex Hours.

Articles: 461

8 Comments

  1. It makes sense to have multiple flows …… enhancing one flow without affecting others is easy. Will this field get auto updated for existing flows out there ?

  2. Holy cow!! This is so great! I can’t believe it’s hidden down in advanced settings. Thanks for pointing it out!

  3. So after getting Spring ’22 this weekend 2/12/22, I was excited to try out the new Flow Trigger Explorer (I also spent about 40 minutes trying to find Flow Orchestrator, which is buried under the 2nd tab when you click New Flow – All + Templates, but nowhere else to be found in Setup despite numerous beta videos showing it there).

    I quickly learned that in typical Salesforce .10 Beta release style, even after you order the triggers (only way seems to be by manually clicking into each one and re-saving a new version, one at a time!) the Flow Trigger Explorer still shows them in random order!

    It also claims to be “Sorted by Flow Label” (non-customizable) at the top of each section, yet it is NOT–it is sorted by the API names, not the display names (labels)! It also seems to do some strange stuff, like ignore parenthesis and perhaps other non-alphabetic characters when sorting. For example, it ordered my flows like this:

    (ADMIN) Admin flow 1
    Lead 210: before save | Flow 1
    Lead 270: before save | Flow 4
    Lead 220: before save | Flow 2
    Lead 230: before save | Flow 3
    (TEST) Test flow
    (TEST) Test flow

    I assume it’s ignoring the parenthesis, and just using the first non-special character in the API name to display them.

    So essentially the only way to get your flows to sort in the order you actually trigger them, is to apply a strict naming convention, then RE-SAVE EVERY SINGLE FLOW as a new flow (v1, losing all your flow history) so that the API name is changed as well and the Trigger Explorer will sort them in the same order as your naming convention (which includes a number matched to the trigger order).

    Also, Trigger Order does not seem to be a visible field exposed (so I can’t even add it to the List View to sort). Worse, when I pushed my flows from Sandbox to Production after ordering them, it doesn’t copy the trigger order–they all remained blank!! (Both orgs are on v54)

    So lame. :-\

    Do you know where Salesforce is storing this new Trigger Order value, so I can add it to my package.xml to copy all my flows to Production without having to re-save each one again, one at a time??

  4. Answering my own question here…. If using deployment tools, you have to update your package.xml from version 53 to version 54 in order for the <triggerOrder> tags to be downloaded/uploaded with your code:

    <?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
    <Package xmlns=”http://soap.sforce.com/2006/04/metadata”>
    <types>
    <members>*</members>
    <name>Flow</name>
    </types>
    <version>54.0</version>
    </Package>

    Once I did that, then the new triggerOrder XML appeared in each flow metadata file below and could be easily copied from sandbox/to production using VS Code or the CI/CD tool of your choice! 🙂

    <triggerOrder>240</triggerOrder>

  5. Looks like in addition to updating your package.xml and each flow metadata file to version 54, you also have to update your sfdx-project.json:

    “sourceApiVersion”: “54.0”

    Otherwise you receive the error “Property ‘triggerOrder’ not valid in version 53.0” (or whatever prior version you’re on) when you try to deploy.

  6. Anyone knows what happens if not all the flows on object have the Trigger Order field filled in? How would Salesforce order flows with blank fields against ordered flows?

  7. I have few doubts and need your help:
    What is “New Trigger Order” means and how Salesforce is setting the value?
    e.g.:
    For I have a “flow: Review Opportunity with Account Owner” inside Trigger explorer by default is 1500 but
    in my org, I have only 7 flows on “Opportunity” object.

    thanks!

Leave a Reply

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