How to tell Process Builder to “Do Nothing”

nothing1

As you may have seen in my previous post about how to make one Process Builder execute before another Process Builder, I used an action called “Do Nothing”.

How does Process Builder determine its next steps?

d1When a criteria node gets evaluated in Process Builder, it is either True or False.  From there the flow continues to the next criteria node if the evaluation was False or executes one or more actions if the result was True.

After your action(s) execute, you can have the Process Builder stop or continue on to the next node just like it would have if your criteria had been false.

Why would I want to tell Process Builder to do nothing?

pb2dMy use case in setting the order of execution for a couple of Process Builders required that one of my Process Builders would test to see if it was its turn to execute and if it was not, it would stop.

But, in order to stop, the Process Builder requires that at least one action be defined.  When faced with the need to create an action that doesn’t really need to do anything, most administrators probably just create an Update Records action that sets a field equal to itself.

d2

To me, this seemed a bit cumbersome.  I wanted to find a way to create a reusable action that I could easily put in any Process Builder and have it do nothing.

action-typesAll of these actions are designed to do something.  They are either unique to the object your Process Builder is built around, require some additional information, or need a link to something else that already exists like a Chatter Group or email template.

My first attempt was to create an invocable Process Builder that I named “Do Nothing”.  It had one criteria node that was always False (Formula: 1=0) and one action that would never get executed.  My action was the “No Change” update shown above.

The primary drawback to this solution was that I would need to create a new invocable Process Builder for each different object I was working with.

Another solution was to create an Apex class that didn’t do anything and just call that as my action.

public class Do_Nothing {
@InvocableMethod
public static void doNothing() {}
}

This works for any Process Builder on any object.  However, it is ‘code’ and not ‘clicks’ and you do have to create and deploy it from a sandbox.

How to build your “Do Nothing” Visual Flow

My final solution was to create a Visual Flow that I could call from any Process Builder on any object and have it do all of the nothing I needed to have done.

nothing2

Steps:

  1. Create a new Visual Workflow and add an Assignment stepd3
  2. Name the step Do Nothing and give it a descriptiond4
  3. Create a new variable to use in your assignmentd5
  4. Set your assignment step as the flow’s start elementd6
  5. Name your flow Do Nothing and save it as an Autolaunched Flow and don’t forget to Activate your flow
    d7
  6. In Process Builder, pick Flows as the Action Type and select your new Do Nothing flowd8

There you go – Something for Nothing!


Update: November 14, 2016


Tip for Visual Workflow:

Say you are trying to debug something where you are using an Autolaunched Flow that is called from Process Builder.  If you want to temporarily disable your Flow and try to deactivate it, you will get an error when running your Process Builder.

Just update your Flow to include the “Do Nothing” step, don’t connect it to anything and make it your start element.

f1

Activate the “Do Nothing” version and your Process Builder won’t generate the missing flow error.

f2

Be sure to change the description so you’ll know what version you’ll need when you’re debugging.

 

 

Advertisements

3 thoughts on “How to tell Process Builder to “Do Nothing”

  1. Nice trick, Eric! I have to say, this was a very humorous story to read and I enjoyed walking down the pros/cons of the various solutions you considered. I about burst outloud laughing when I read the post-it “Todo: Nothing”. Thanks!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s