How to pass your current RecordID in your screen flow
How to do it from a Lightning Page or a Quick Action
Overview
This guide shows you how to pass the current record's ID to a screen Flow in Salesforce. This is essential when you want your Flow to interact with the specific record a user is viewing (e.g., an Account, Contact, or Opportunity). Your Flow can access and work with the correct record data by sending the record ID.
Setting Up Your Flow and App Builder
To connect your Flow to a record and pass its ID, you must configure the Flow itself and the Lightning App Builder page where the Flow will be displayed.
Step 1: Create a recordId
Variable in Your Flow
recordId
Variable in Your FlowFirst, you'll create a variable within your Flow to store the record ID. This variable acts like a container that will receive the ID from the record page.
Open Your Screen Flow: In Salesforce Setup, go to Flows and open the screen Flow you want to use.
Open the Toolbox: In the Flow Builder, find the Toolbox (usually on the left-hand side).
Create a New Resource: Click the "New Resource" button.
Select "Variable": Choose "Variable" as the Resource Type.
Name the Variable
recordId
: In the "API Name" field, enterrecordId
. Using this exact name is a best practice and clarifies what the variable holds.Set Data Type to Text: Select "Text" as the Data Type. Record IDs are text strings.
Crucial: Enable "Available for Input": Check the box labeled "Available for Input". This is essential because it allows the variable to receive the record ID outside the Flow (from the App Builder).
Click "Done": Save the new variable.
Step 2: Add the Flow to Your Record Page and Pass the Record ID
Now, you'll add your Flow to the Lightning record page and configure it to send the record ID to the recordId
variable.
Open the Record Page in App Builder:
Go to Setup.
Search for and select "Lightning App Builder."
Find the Lightning record page you want to modify (e.g., the Account Record Page) and click "Edit."
Drag the Flow Component onto the Page: In the App Builder, find the "Flow" component in the component list (usually on the left) and drag it to the desired location on your page layout.
Select Your Flow: In the Flow component's properties panel (on the right), use the "Flow" dropdown to select the screen Flow you created in Step 1.
Important: Pass the Record ID: You'll see a section in the same properties panel (likely labeled "Set Input Variables" or similar). Crucially, check the box that says "Pass record ID into this variable". This setting automatically connects the current record's ID to the
recordId
variable you created in your Flow. This is the key step that makes everything work.Save and Activate: Click "Save" in the App Builder, and click "Activate" if prompted. This makes your changes live.
Problems?
If you don't see the RecordID checkbox in App Builder, please complete Step 1 first.
Configuring a Quick Action to Pass the Record ID to a Flow
This guide shows you how to pass the current record's ID to a Flow launched from a Quick Action in Salesforce. This is essential when you want a button or link on a record page to start a Flow that interacts with that specific record. By sending the record ID, the Flow knows which record's data to use.
Step 1: Create a recordId
Variable in Your Flow (if you don't have it already)
recordId
Variable in Your Flow (if you don't have it already)Your Flow needs a variable to store the record ID it receives from the Quick Action.
Open Your Flow: In Salesforce Setup, go to Flows and open the Flow you want to use with the Quick Action.
Open the Toolbox: In the Flow Builder, find the Toolbox (usually on the left).
Create a New Resource: Click the "New Resource" button.
Select "Variable": Choose "Variable" as the Resource Type.
Name the Variable
recordId
: In the "API Name" field, enterrecordId
. This is a Salesforce best practice.Set Data Type to Text: Select "Text" as the Data Type.
Crucial: Enable "Available for Input": Check the box labeled "Available for Input." This allows the variable to receive the record ID from the Quick Action.
Click "Done": Save the variable.
Step 2: Create and Configure the Quick Action
Now, you'll create the Quick Action that will launch your Flow.
Go to Object Manager: In Salesforce Setup, go to the Object Manager and select the object where you want to add the Quick Action (e.g., Account, Contact, Opportunity).
Create a New Action:
Click on "Buttons, Links, and Actions."
Click the "New Action" button.
Configure the Action:
Action Type: Select "Flow." This tells Salesforce that this Quick Action will launch a Flow.
Flow: Choose the Flow you created (and configured with the
recordId
variable) in Step 1.Label: Enter a user-friendly label for the Quick Action (e.g., "Update Contact," "Create Task"). This is what users will see.
Name: The API name will be automatically generated from the Label. You usually don't need to change this.
Description: (Optional) Add a description for your own reference.
Crucial: Pass the Record ID:
Locate the section called something similar to "Predefined Field Values".
There's no need to 'add an input variable'.
Set the Target Object as your flow.
Set a field value. In the field, look for
recordId
(your flow variable) and set the value as{!$Record.Id}
. This is critical: it tells the Quick Action to send the current record's ID to therecordId
variable in your Flow.
Save the Quick Action: Click "Save."
Step 3: Add the Quick Action to the Page Layout
Finally, make your Quick Action visible to users by adding it to the object's page layout.
Go to Page Layouts: In the Object Manager for the same object (e.g., Account), click on "Page Layouts."
Edit the Page Layout: Select the page layout you want to modify.
Add the Quick Action:
In the page layout editor, click on "Mobile & Lightning Actions" in the palette.
Find the Quick Action you just created (it will have the Label you gave it).
Drag and drop the Quick Action to the "Salesforce Mobile and Lightning Experience Actions" section of the page layout. Place it where you want it to appear for users.
Save the Page Layout: Click "Save."
Step 4: (Optional) Using the recordId
in Your Flow
recordId
in Your FlowNow that the record ID is being passed to your Flow, you can use it within the Flow elements. Here's a common example:
Add a "Get Records" Element: In your Flow, add a "Get Records" element.
Configure the Element:
Object: Choose the object you want to retrieve data from (e.g., Account, Contact, Opportunity – often the same object as the Quick Action).
Filter Records Condition Requirements:
Field: Select
Id
(the standard ID field for the object).Operator: Choose "Equals".
Value: Select the
recordId
variable. This tells the "Get Records" element to fetch the specific record whose ID was passed from the Quick Action
You're done! Now, when you click the Quick Action on a record page, it will launch your flow and pass the current record's ID, allowing your flow to work with that specific record.
Last updated
Was this helpful?