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:
- Processes invoke Processes
- Processes invoke Flows
- Flows invoke Flows (sub-flows)
- ... but Flows could not invoke Processes ...
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 Connected App (documentation)
- In Setup, navigate to
Create | Apps. - Find Connected Apps section then click New button
- Enter a name for your app (e.g. Salesforce Process Invocable)
- Enter your admin email address
- Callback URL, for now, just enter https://localhost.com but we will change this later
- Select OAuth Scopes
Full accessandPerform requests on your behalf at any time - Click Save button
- Take note of the generated Consumer Key and Consumer Secret values
Create Auth Provider (documentation)
- In Setup, navigate to
Security Controls | Auth. Providers - Click New button
- Provider Type, choose Salesforce
- Enter a name for your auth provider (e.g. Salesforce Process Invocable)
- Consumer Key, enter the value from your Connected App
- Consumer Secret, enter the value from your Connected App
- Click Save button
- Copy the generated Callback URL and update your Connected App with this new value. Once the Connected App's callback url is updated, do wait 10 minutes for the change to propogate otherwise you may get errors in the final step of setup.
Create Named Credential (documentation)
- In Setup, navigate to
Security Controls | Named Credentials - Click New Named Credential button
- Enter a label for your named credential (e.g. Salesforce Process Invocable)
- Enter the URL to your Salesforce instance (e.g. https://login.salesforce.com or your My Domain like https://yourdomain.my.salesforce.com)
- Identity Type, choose either "Named Principal" or "Per User". For testing, it's far easier to choose "Named Principal".
- Authentication Protocol, choose OAuth 2.0
- Authentication Provider, choose the auth provider you created in earlier step
- Scope, enter
full refresh_token - Click Save button, a login page will open
- Follow on-screen instructions to login as the context user you want to assign to this Named Credential (I suggest a system administrator)
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








