<img alt="Deploy to Salesforce" src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png">
Invocable Processes were introduced in the Winter '17 release.
So at the time of the release, these were the ways in which Processes and Flows could be invoked by each other:
This solution fills that gap.
Also note in the Winter '17 release that the ability to invoke Processes is available in the Actions REST API. This code fills the functionality gap to enable Flows to invoke Processes by way of invocable apex that makes the http request to the REST API.
The benefit is that Flows can on-demand call reusable Processes!
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.
Since the Salesforce REST API requires OAuth authentication, we have to use Named Credentials. If you are already familiar with setting these up then skip to the Usage section.
Follow these steps to setup a Named Credential that authenticates to your Salesforce org. The name of this Named Credential will be used when you create your Flow to use the ProcessInvocable element.
Create | Apps
.Full access
and Perform requests on your behalf at any time
Security Controls | Auth. Providers
Security Controls | Named Credentials
full refresh_token
Create an invocable Process
Create a Flow that uses the ProcessInvocable Apex action from the palette
You can pass multiple Salesforce record IDs to the Process you want to invoke.
Or, you can pass single Salesforce record ID to the Process you want to invoke.
These are the input parameters when configuring the ProcessInvocable element on the Flow canvas.
Parameter Name | Description | Required? |
---|---|---|
Process Name | Unique API Name of the Process or Flow to invoke. | Yes |
Named Credential | The Named Credential to use to authenticate to Salesforce REST API when making http callouts to invoke the Process or Flow. | Yes |
API Version | The REST API version to use when calling Actions API to invoke the Process or Flow. Should be 38.0 or greater. | Yes |
Record IDs | Variable Collection of Salesforce record IDs that the Process or Flow will execute on. Must all be of the same object type. Either Record IDs or Record ID must be specifid. |
No |
Record ID | Salesforce reocrd ID that the Process or Flow will execute on. Either Record IDs or Record ID must be specifid. |
No |
When needing to run multiple records through the same Process, build up a Collection Variable
in your Flow then use the Record IDs
collection input parameter.
For performance, this will make one HTTP request to the REST API passing in all the record IDs together rather than making multiple HTTP requests.
https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_intro_invoking.htm