How to make one Process Builder execute before another Process Builder

me-first

What is the order execution in Salesforce?

It is all laid out in Salesforce’s Triggers and Order of Execution.  Every type of trigger and action happens in a set order.  What is not set is the order of execution of items of the same type such as a collection of Process Builders.

If your use case requires that a particular Process Builder gets executed before another one then you will need to control the sequence yourself.  One option is to redo all Process Builders for a single object as invocable Process Builders and then call them in order from a controlling Process Builder.

Not wanting to recreate my Process Builders from scratch, I used a different technique to put two Process Builders in the order I wanted.  I had the first Process Builder set a value that the second one looks for.  The second Process Builder will not continue execution if the first hasn’t yet executed and set the value.

My Problem:

I have two Process Builders that I created to act on the Opportunity object.  One contains most of the workflow I’m doing when the Opportunity record changes.  The other one was only for updates I needed when the Opportunity record was created.  This should be fairly straight forward except that the Record Update Process Builder was executing before the Record Create Process Builder.

My Solution:

I was able to resolve the sequence the Process Builders executed by  first creating a checkbox field in my Opportunity that would default to checked when a record was created.  Then my Opportunity Create Process Builder would clear the checkbox as its last action.  My Opportunity Change Process Builder first tests the checkbox and only continues if it has been cleared.

Steps:

  1. Create a custom field on the Opportunity object.  The field type should be Checkbox with a default value of Checked.  This field does not need to be on any page layouts.field
  2. Add a final criteria step in the “Opportunity – Record Create” Process Builder.  This just needs to execute the actions without testing for any criteria.
    pb1d
  3. Add an action to clear the checkbox field.
    pb1t
  4. Add a first criteria step in the “Opportunity – Record Changes” Process Builder.
    PB2d.png
  5. The criteria should check if the checkbox field is still checked.
    pb2t
  6. Continue on with the rest of the Process Builder only if the result is False.

Conclusion:

With the new field added to Opportunity and the added steps in my Process Builders to test or clear the field, I am able to force my “Opportunity – Record Create” Process Builder to always execute before my “Opportunity – Record Changes” Process Builder when a new Opportunity record is created.

You probably noticed that the first Immediate Action in my Record Update Process Builder says “Do Nothing”.  Read my next post to find out how to tell your Process Builder to do nothing.


Here’s how to produce your own Process Builder OneView documentation as seen in this post.

5 thoughts on “How to make one Process Builder execute before another Process Builder

  1. HI Eric
    When i tried implementing the same to sequence the order, PB-1 dint run , PB-2 started and checked that value is not set to ‘True’ yet and dint enter to PB-2. Transaction got over, it dint go back to PB-1 again. So eventually both PB dint run.

    Am i doing something wrong!

    Like

  2. Eddie’s suggestion is the best option. Then you can arrange the nodes within the PB in the order they should fire. Recursive can cause issues.

    Liked by 1 person

Leave a comment