Flow is great for building interactive workflows right into the Salesforce user interface. This post discusses how to run a Screen Flow at the click of a button on a record detail page.
First, a reminder. There are two main types of Flow: Screen Flows and what Salesforce calls "Autolaunched" Flows. Autolaunched Flows aren't interactive. They run in the background based on some trigger: a record change, a platform event or on a schedule.
Screen Flows are meant to be used by users in user interfaces; they're 100% interactive. To support this, the Flow Builder provides all kinds of UI and screen-building capabilities for Screen Flows.
So let's see how you can connect a Screen Flow to a button on a record detail page to automate a process.
Let's say we have a sales process at Acme Co where a business development rep (BDR) performs in initial discovery with a prospect. Acme is very ABM-focused, so BDRs use opportunities instead of leads. If their prospect is qualified, the BDR needs to assign the opportunity to an Account Executive (AE) who will then take over the sales cycle. To make this easy, we'd like our BDR to be able to press a button and assign the opp to an AE via round-robin.
Configure your action
Let's assume for now that you've got a screen flow that handles the round-robin assignment and it's all set up and activated. In our case, we've got a Screen Flow called "Assign Opportunity" that's all set up and ready to go. We'll cover a bit more about the Flow itself later in this post.
First, go to Setup > Object Manager and locate the object you want to add the button to. That's the Opportunity object in our case. On the left side of the screen, select "Buttons, Links and Actions" and then click "New Action". (Even though this will end up looking like a button in the UI, we're not going to use "New Button or Link". That's a different, older thing. Salesforce gonna Salesforce ¯\_(ツ)_/¯.)
The New Action screen looks like this:
Change the Action Type  picklist to Flow. The next field will change to a picklist of available Screen Flows . If you don't see your Flow in this list, go back and check that a) it's a Screen Flow, not an Autolaunched Flow and b) that you set it to active in the Flow Builder.
Select your Flow.
Enter a Label and Name, then click Save. Note that the label is what the text the button will show in the UI so keep it fairly short.
Go to Page Layouts in the left nav and click into the page layout you're using for this record type:
In the layout controls, select "Mobile & Lightning Actions". You should see your new action listed there. Drag it into the "Salesforce Mobile and Lightning Experience Actions" section. (If your "Salesforce Mobile and Lightning Experience Actions" section doesn't look like the above, you may need to click the little wrench icon to allow you to modify it.) Click Save.
You're all set. Now it's time to see your action in... action. Navigate to a record detail page and you should see your action translate into a button in the Lightning UI like so:
If you don't see the button, try the little dropdown arrow to the right of the buttons. Your action may be hiding in there.
Click the button and your Flow will execute, showing you whatever screens you've designed in a dialog. Our Gradient Works Flow says who the new assigned AE is and looks like this:
Once you click next, the dialog goes away and that's it.
If that's all you needed, you can stop now. If you want to know a little more about how to build a Screen Flow that works like this, read on.
Building the Screen Flow
We skipped right to the button part and just assumed you have a working Screen Flow. If that's not the case, let's talk a little about how to set up your Flow for the use case above.
Fair warning, the rest of this section uses Gradient Works to do opportunity assignment in Flow. If you don't have Gradient Works, some of the Flow assignment actions described won't be available to you.
Our goal here is to make a Flow that assigns a new owner to the Opportunity record the user is viewing, so we need to make the Flow aware of the record it's operating on. You do this by creating an input variable in the Flow called recordId.
Here's what that looks like:
Make sure you name the variable recordId , set the Data Type to Text  and make the variable "Available for Input" . When you set things up this way, Salesforce will automatically set this variable to the Id of the record the user is viewing when they click the button.
Our Flow is actually pretty simple. It just needs to perform the following steps in order:
- Get the opportunity
- Assign the opportunity to an AE
- Show a screen with the assignment results
- Refresh the record detail page to show the new data
Here's what the completed Flow looks like:
Let's look at each of the 4 elements in turn.
Get Opportunity is a Get Records element and it uses the recordId variable we created to fetch the Opportunity that the user is viewing. Here's what the Get Records config looks like:
Assign Opportunity uses a Gradient Works custom Flow Action that allows you to do adaptive round-robin assignment to a group of users. This action takes an "item" (the Opportunity record retrieved by our previous Get_Opportunity action in this case) and the name of a Gradient Works Queue ("AEs") where the pool of potential users has been defined for assignment. Here's the configuration for the action:
One cool thing about this action is that it outputs an Assignment that contains info about who was assigned to the record. In this case (not shown), we store that output in a variable called Assignment so we can use it in the next step.
The next step is all about showing what was assigned to whom in a dialog. Here's what that Screen Element setup looks like:
We use the Assignment output from the Assign Opportunity step to display a message to the user using merge fields.
Finally, we have one more step which is a little odd. We need to explicitly tell the record detail page to refresh. If we don't, it won't be obvious to the user that the owner has changed. The last action is a Gradient Works action that forces a refresh to occur and looks like this:
And that's it. Those 4 elements create a Screen Flow that does a round-robin assignment of an Opportunity to a group of AEs and then displays the result to the user. With some tweaks, the assignment logic could become much more powerful with specific checks for Opportunity stage and assigning users from multiple round-robin queues.
With a few clicks, you can quickly add an action button on a record detail page that your users can use to kickoff context-aware, interactive Screen Flows and get more done. While our Screen Flow used Gradient Works, your Screen Flow can be any workflow you want to automate.
You may also want to check out our Flow cheatsheet - a quick reference guide to help you work through most any Flow issue.