Since Winter ’17 release introduced invocable processes and now we can design solutions with reusable processes, it got me thinking about how much reuse we could get out of Process Builder and Flows, two of the most powerful declarative automation features in the platform!

So at the time of the release, these were the ways in which Processes and Flows could be invoked by each other:

Well, to my knowledge, Salesforce does not have a way to let Flows call invocable Processes, the Flow would have to create or update a record to cause Process Builder to fire in the traditional manner.

This solution is my workaround to enable Flows to call invocable Processes!

How it works is that this solution fills the functionality gap to enable Flows to invoke Processes by way of Invocable Apex that makes an http callout to the Actions REST API.

The benefit is that Flows can on-demand call reusable Processes! Not convinced how awesome this is? Check out Jennifer Lee’s Dreamforce 2016 session on componentized Processes and Flows. The magic is in DRY principles (don’t repeat yourself). Build once, reuse everywhere!

Getting Started

Please note, since the Salesforce REST API requires OAuth authentication, we have to use Named Credentials when making the http request, so there is some extra setup by the admin and potentially by the end-users before this solution can be used.

Please see my github repo for full setup instructions.

Deploy to Salesforce

1. Create an Invocable Process

invocable-process

2. Create a Flow that uses the ProcessInvocable Apex Action from the canvas palette

flow-invoke-process

3. Configure the ProcessInvocable Apex Action to call your Process.

  • API Version – The REST API version to use when calling Actions API to invoke the Process or Flow. Should be 38.0 or greater.
  • Named Credential – The Named Credential to use to authenticate to Salesforce REST API when making http callouts to invoke the Process or Flow. You create this once during Setup.
  • Process Name – Unique API Name of the Process to invoke.
  • Record IDs – Variable Collection of Salesforce record IDs that the Process will execute on. You can alternatively specify Record ID input parameter if you’re only working with a single record.

flow-invoke-process-multiple-records

flow-invoke-process-single-record