Start tracking your progress
Trailhead Home
Trailhead Home

Add a Flow as an Action on a Record

Learning Objectives

After completing this unit, you’ll be able to:
  • 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.

Use Case Example
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.

Flow Actions

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.

Flow Action on a record in Lightning Experience

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.

Flow Action in Salesforce app action bar

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.

  1. From Setup, click the Object Manager tab. Click Contact, then click Buttons, Links, and Actions.
  2. 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.

  3. Save the action.
  4. 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!
    1. From Setup, click the Object Manager tab. Click Contact, then click Page Layouts.
    2. Click Contact Layout.
    3. In the Salesforce Mobile and Lightning Experience Actions section, click override the predefined actions if present.
    4. Select Mobile & Lightning Actions in the palette, and then drag your action to the Salesforce Mobile and Lightning Experience Actions section.
      Dragging Flow Action into Salesforce Mobile and Lightning Experience Actions
    5. Click Save.

Test Your Flow

Now let's make sure everything's working as we expect. Use the App Launcher App Launcher icon to switch to the Sales app, then open up a contact record.A flow action in the contact record for Ms. Rose Gonzalez.

Notice that the page-level action menu includes Flow Action. That's the one we created. Let's see it in action. Click Flow Action.A Flow Action modal over the contact record for Ms. Rose Gonzalez. The modal's title is Flow Action, and it's displaying the Sample Flow flow.

The flow opens up in a separate window. Notice that the title shown isn't the name of the flow, “My Screen”. It's the label we gave the action, “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.

Resources

Lightning bolt icon used to indicate that the content is for Lightning Experience

Remember, this module is meant for Lightning Experience. When you launch your hands-on org, switch to Lightning Experience to complete this challenge.

retargeting