Infinite Flow

UPDATE - 7-7-15: This will eventually trigger an error, and is a known issue w expected behavior ‘TBD’. See updated post - Infinite Flow Refined. for more details on the error and the infinite flow model

It is possible to set up a recurring event (say a birthday reminder that fires every year) using 2 workflow rules. Its not all that pretty, but it works.

There are open ideas for recurring time based rules, including one that was marked as delivered in spring 15 via process builder.

I set about trying to build such functionality using process builder, and had a hard time getting it to work as there are a lot of options to poke around with, its hard to debug processes, and so on.

Since process builder on the back end spits out a flow, I thought I might have better luck there, and indeed I did. So I shall demonstrate how to build a flow that continues, forever.

Sample use case: Fire a reminder on open opportunities every X. For the demo i will have it post to chatter every hour. My actual use case is to fire a reminder on open opportunities every 6 months that the opportunity is not modified - but that is for a later more detailed post as I’m still working out the best way to do this.

The post-every-hour flow is quite simple.

infinite_flow.png

It starts with a wait element, that waits for 1 hour from the rule being triggered.

After an hour, the flow posts to chatter

Then we enter into another wait element, that waits for 1 hour

Then we post to chatter, and run back into the first wait element, building the infinite flow loop!

I had serious doubts that I would be able to save or run this flow, but it works! And it will go on forever.

infinite_flow_in_action.png

I launched this rule w/ a flow trigger, b/c its a demo and its faster to build those. Criteria were that opp is created / edited and is open, and didnt meet criteria before.

Some stuff I didnt do in the demo that would be needed in a real use case:

  1. Add a lookup and a decision element before the post, to ensure that the criteria are still met. This will fire forever. It will never, ever stop (until you have so many of them that you hit your governor limits). You likely could pull this off using criteria in the wait element, allowing you to use fewer or no lookup elements. I have not tested yet.

  2. Add fault behavior to the wait elements

This opens up lots of interesting options, and also should be used w/ care. Governor limits are there for good reason!

 
6
Kudos
 
6
Kudos

Now read this

Determining which fields are used in a page layout (in less time than it takes to brew a cup of coffee)

There is a great app called FieldTrip that will let you know which fields are actually populated in records, but deep diving into eclipse, or using brute force, have been the only way that I am aware of to see which ones are actually... Continue →