<span id="hs_cos_wrapper_name" class="hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text" style="" data-hs-cos-general-type="meta_field" data-hs-cos-type="text" >How to launch a Salesforce Screen Flow from a button</span>
05/21/2021

How to launch a Salesforce Screen Flow from a button

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 ¯\_(ツ)_/¯.)

Salesforce Opportunity object Buttons, Links and Actions section

The New Action screen looks like this:

Salesforce Opportunity New Action

Change the Action Type [1] picklist to Flow. The next field will change to a picklist of available Screen Flows [2]. 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:

Salesforce Opportunity page layout editor showing how to drag the Assign AE action into the layout

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.

Click it!

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:

Salesforce Opportunity record detail page with Assign AE button

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 Assignment Flow says who the new assigned AE is and looks like this:

Salesforce Screen Flow dialog indicating the opportunity was assigned

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.

Start by creating a new Screen Flow in the Flow Builder or click New in the Automation tab in Gradient Works.

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:

Salesforce Flow new resource screen for the recordId variable

Make sure you name the variable recordId [1], set the Data Type to Text [2] and make the variable "Available for Input" [3]. 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:

  1. Get the opportunity
  2. Assign the opportunity to an AE
  3. Show a screen with the assignment results
  4. Refresh the record detail page to show the new data

Here's what the completed Flow looks like:

Salesforce assignment Flow in full

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:

Salesforce Flow new Get Records action

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:

Gradient Works Assignment Flow 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:

Screen Flow dialog config in Screen element

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:

Salesforce Flow new action for refreshing the record detail page

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.

Wrapping up

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 Assignment, your Screen Flow can be any workflow you want to automate.

Happy flowing.

Related Posts

Get more from your Flow

The Gradient Works team loves Salesforce Flow. Seriously, we do. And we'd love to help you with your Flow setup. Want a free consultation? Let's talk. No strings attached. 

Sign up for a free consultation