You are here:
Run a Flow from a Custom Record Page Button
Add a custom button to a record page that starts an active autolaunched flow or screen flow. Send any variable value to the flow. Use the flow's web address (URL) to set up the button.
Required Editions
| View supported editions. |
| User Permissions Needed | |
|---|---|
| To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: | Manage Flow |
Create a Flow
Create an autolaunched flow or screen flow to launch from the button. Optionally, you can send the ID of the record where the button is clicked to the flow. To send the record ID to the flow, so the flow knows what record to work on, create a flow variable called recordId to hold the ID.
-
Open the Flows list view.
- From Setup, in the Quick Find box, enter Flows, and then select Flows.
- From the Automation app, select the Flows tab.
- From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
-
Create an autolaunched flow or a screen flow.
- From the Lightning app, click New. Then select Autolaunched Flow (No Trigger) or Screen Flow.
- From Setup, click New Flow. Then select Autolaunched Flow (No Trigger) or Screen Flow.
Flow Builder opens. -
Optionally, add a text variable to store the record ID.
-
To open the Toolbox, click
.
- Click New Resource, and then select Variable.
- For API Name, enter recordId.
- For Description, enter Stores the ID of the record that the button is located on. This value is passed into the flow.
- For Data Type, select Text.
- Select Available for input.
- Click Done.
-
To open the Toolbox, click
- Optionally, add more variables to store additional input values that are sent to the flow when it runs. Learn about adding input values, in addition to the record ID, to the URL in Send Variable Values to a Flow Using the Flow's URL.
-
Add elements to your flow to perform the actions you want.
For example, if the flow has the ID of the contact sent into the flow, you can use a Send Email action to email the contact by setting Record ID to the recordId variable.
- Save the flow.
- Test the flow by clicking Debug and using test data.
- Click Activate.
Get Your Flow's URL
- From Setup, in the Quick Find box, enter Flows, and then select Flows.
-
For the flow that you want to run, click
, and select View Details and Versions.
-
Copy the flow's URL.
The format of the URL is /flow/My_Flow.
Create a Custom Button
- From Setup, click Object Manager.
-
Click the object that you want to add a record page button to. For example,
Contact.
The object window opens.
- Click Buttons, Links, and Actions.
- Click New Button or Link.
- Give the button a label and name.
- For Display Type, select Detail Page Button.
- Leave the default values for the remaining fields.
-
In the large text box, enter your flow's URL, and then add
/lightning to the start of the URL.
The full text looks like
/lightning/flow/My_Flow. -
If you want to pass the ID of the record that the button is located on, add the value of
the recordId input variable in the URL. For example, if the button is located on account
records, enter ?flow__recordId={Account.Id}. So the full URL is
/lightning/flow/My_Flow?flow__recordId={Account.Id}. - Save your work.
Add the Custom Button to the Page Layout
- Click Page Layouts.
- Click the page layout that you want to add the link to.
- Click Buttons.
- Drag and drop your button from the buttons list to the object detail section. For example, the Account Detail section.
- Save your work.
Now, users can go to a record, click the button you created, and start the screen flow or autolaunched flow. If you set up input variables, those values are sent to the flow when the user clicks the Next button on the screen flow or when the autolaunched flow starts running.

