Add a Flow as an Action on a Record
- Describe use cases for adding a flow as an action.
- Create a flow action, and add it to a page layout.
With Lightning App Builder and Record pages, we can add flows to any record. But, remember when we said that when you add a flow to a page, the flow runs its first screen every time the page loads? There are some situations where it makes sense to have the user decide when they're ready to launch a flow. Here are some use cases.
The first element in the flow isn't a screen. The power of a flow is that it can do a lot of things behind the scenes, with the user none the wiser. But that can also make the flow a little bit dangerous, especially if it does those powerful, behind-the-scenes things before the first screen.
||You built a flow that creates a task before displaying a screen to the user. If you put that flow on, say, the Account page, that flow would create a task every time a user loaded an account. That could result in lots of unnecessary tasks being created each day.
|The flow isn't used often enough to be expanded by default.||You created a flow for your office managers to order new supplies. The office managers need to be able to access that flow easily, but they don't need to order supplies every day, so it would be a waste of space to put the flow directly on a record page.
A flow action is a custom action that renders a flow, and as such it’s perfectly suited to these kinds of use cases. Once you create a flow action and add it to a page layout, it appears in the associated record's page-level action menu in Lightning Experience where users can find it to launch the flow.
Similarly, a flow action can be placed in the record's action menu in the Salesforce app. Flow actions aren't supported in Salesforce Classic.
Create a Flow Action
Let's quickly create a flow action. We're doing this for contacts, but you can create actions for most objects.
- From Setup, click the Object Manager tab. Click Contact, then click Buttons, Links, and Actions.
- Click New Action and set these values.
Field Value Action Type Flow Flow Select the flow we created in the first unit: Sample Flow Label Enter Flow Action
Users see this label, rather than the flow label, as the name of the action.
- Save the action.
- Just like any other action, creating a flow action only gets you halfway there. Don't forget to add it to the appropriate page layout. Otherwise, your users can never reap the benefits of your labors. The horror!
- From Setup, click the Object Manager tab. Click Contact, then click Page Layouts.
- Click Contact Layout.
- In the Salesforce Mobile and Lightning Experience Actions section, click override the predefined actions if present.
- Select Mobile & Lightning Actions in the palette, and then drag Enter Flow Action to the Salesforce Mobile and Lightning Experience Actions section.
- Click Save.
Test Your Flow
Now let's make sure everything's working as we expect. From the App Launcher ( ) find and select the Sales app, click Edge Communications, then open a contact record.
Notice that the page-level action menu includes Enter Flow Action. (You may need to click the down arrow to see Enter Flow Action.) That's the one we created. Let's see the flow action...in action. Click Enter Flow Action.
The flow opens up in a separate window. Notice that the title shown isn't the name of the flow, “Sample Flow”. It's the label we gave the action, “Enter Flow Action”. We kept the names different here to show you what’s what. When you create flow actions for your own use cases, we recommend entering the flow label as your action's label.