How to Pass a Record ID into Salesforce Flow

Imagine a sales representative is viewing an Opportunity and clicks a button to start a Flow. Salesforce should already know which Opportunity the user is working with. The user should not have to search for or select the same Opportunity again.

The same requirement is common in other Salesforce processes. For example, a support agent may open a Case and launch a guided Flow to create follow-up work. In this situation, the Flow needs to know exactly which Case the agent is working on.

This is where passing the current Record ID into a Salesforce Flow becomes useful.

I have used this pattern in multiple Salesforce implementations because it makes Screen Flows much easier for users.

Instead of asking users to manually search for a record, we can pass the current record’s unique Salesforce ID directly to the Flow.

Once the Flow receives the Record ID, it can use that ID to:

  • Find the related record.
  • Display record information on a Screen.
  • Update the current record.
  • Create related records.
  • Create follow-up Tasks.
  • Perform additional business logic.

In this step-by-step Salesforce tutorial, we will learn how to pass the current Record ID into a Screen Flow from a Salesforce record page.

By the end of this tutorial, you will understand how Salesforce passes the current record’s ID to the flow and how you can use that ID to build more user-friendly automation.

What Does Passing a Record ID to Salesforce Flows Mean?

Every record in Salesforce has a unique Record ID. This includes records such as Accounts, Contacts, Opportunities, Cases, and many other Salesforce objects.

When you pass a Record ID into a Flow, you are basically telling the Flow:

“This is the record the user is currently working with.”

The Flow can then use this ID to find the record, read its information, update it, or create related records.

Simple Example

Imagine a Sales Cloud team with 20 sales representatives. A sales rep opens an Opportunity and clicks a “Create Deal Review Task” button.

Instead of asking the rep to search for and select the Opportunity again, Salesforce passes the Opportunity Record ID directly to the Flow.

The Flow can then:

  1. Receive the Opportunity ID.
  2. Get the Opportunity record using that ID.
  3. Check details such as the Opportunity Amount, Stage, Close Date, or Owner.
  4. Create a Task for the appropriate manager.
  5. Associate the Task with the same Opportunity.

For example:

Opportunity → Flow → Opportunity ID → Get Opportunity → Create Task

This makes the entire process automatic and user-friendly.

Why Is This Useful?

Passing the Record ID is much cleaner than creating a Screen where users have to search for the record again.

It provides several benefits:

  • No manual record searching
  • Less chance of selecting the wrong record
  • Faster user experience
  • The Flow knows exactly which record to process
  • Easier to create related records
  • Useful for both standard and custom Salesforce objects

For example, the same pattern can be used when a support agent opens a Case and launches a Flow to create a follow-up Task. The Flow receives the Case ID and immediately knows which Case the Task should be related to.

In short, passing a Record ID gives your Flow the context of the record from which the Flow was launched. This is one of the most useful patterns when building Screen Flows launched from Salesforce record pages.

Before You Pass a Record ID into Salesforce Flow

Before you start passing a Record ID into a Flow, there are a few things you need to set up.

1. Create a Flow

For this example, we will use a Screen Flow that creates a follow-up Task from an Opportunity record.

A Screen Flow can display screens and collect information from users. An Autolaunched Flow, on the other hand, runs without displaying screens and is typically started by another automation, Flow, Apex code, or other supported process.

Because our example will be launched by a user from an Opportunity record page, we will use a Screen Flow.

If you are new to Flow Builder, you can first learn how to create a Salesforce Screen Flow and then review how to create variables in Salesforce Flow Builder.

2. Make Sure Users Have the Required Permissions

The user launching the Flow must have the required access to the Flow, Opportunity object, fields, and Task object used by the Flow.

In Salesforce, access is commonly managed using:

  • Profile – Provides the user’s baseline permissions.
  • Permission Set – Provides additional permissions without requiring changes to the user’s profile.

For example, if your Flow needs to read Opportunity fields and create Tasks, the user must have the appropriate permissions to access those records and fields.

3. What We Will Build

In this tutorial, we will create a simple scenario:

A sales rep opens an Opportunity and clicks a button to create a follow-up Task.

The user should not have to select the Opportunity manually. Instead, Salesforce will pass the current Opportunity’s Record ID to the Flow.

The Flow will then use that ID to identify the Opportunity and create the Task against the correct record.

The basic process will look like this:

Opportunity Record Page → Button/Action → Screen Flow → Opportunity Record ID → Get Opportunity → Create Task

Once you understand this pattern, you can reuse it for many other Salesforce use cases, such as creating related records, updating the current record, displaying record information, or launching guided processes from a record page.

Create the Input Variable in Salesforce Flows

The most important setup step is creating a variable named recordId.

  • Go to Setup and search for Flows.
  • Click New Flow.
  • Select Screen Flow, then click Create.
Create Salesforce Screen Flow
  • In Flow Builder, open the Manager tab.
  • Click New Resource.
  • Set Resource Type to Variable.
  • Enter recordId as the API Name.
  • Select Text as the Data Type.
  • Select Available for input.
  • Click Done.
Create the Input Variable in Salesforce Flows

The recordId variable stores the ID sent by the page, action, or button. The Available for input option is essential. Without it, Salesforce cannot send the current record ID into the Flow.

Use the exact API name recordId, including the lowercase r and uppercase I. Salesforce recognizes this naming pattern when you place a Flow on a Lightning record page.

Retrieve the Current Record ID in Salesforce Flow

Next, use the record ID to retrieve the Opportunity data.

  1. Drag a Get Records element onto the canvas.
  2. Label it Get Current Opportunity.
  3. Choose Opportunity as the object.
  4. Set the condition to Id Equals {!recordId}.
  5. Choose Only the first record.
  6. Select Automatically store all fields.
  7. Click Done.
Retrieve the Current Record ID in Salesforce Flow

This element finds the Opportunity that launched the Flow. You can now use fields such as Amount, Stage, Account ID, and Owner ID in your screens, decisions, or updates.

For example, add a Decision element after Get Records:

  • Outcome label: High Value Deal
  • Condition: {!Get_Current_Opportunity.Amount} Greater Than or Equal to 50000

The Flow can then create a manager review task only for opportunities worth 50,000 or more. If you need help designing branching logic, see this guide to the Decision element in Salesforce Flow.

How to Pass a Record ID into Salesforce Flow from a Record Page

Adding a Flow to a Lightning record page is the easiest way to pass a record ID into Salesforce Flow. It works well when users need a guided process directly within the Account, Contact, Opportunity, or Case page.

Add a Screen to the Flow

For the deal-review example, add a Screen element after the Decision element.

  1. Drag Screen onto the Flow canvas.
  2. Label it Confirm Deal Review.
  3. Add a Display Text component.
  4. Enter a message such as:
You are creating a deal review task for {!Get_Current_Opportunity.Name}.
Current opportunity amount: {!Get_Current_Opportunity.Amount}
  1. Click Done.
Add a Screen to the Salesforce Screen Flow

This screen confirms that the Flow received the correct Opportunity. It also gives the rep a place to add context for the manager.

Create the Task Record for Opportunity in Salesforce Flow

Now create the follow-up Task.

  1. Drag a Create Records element after the screen.
  2. Label it Create Deal Review Task.
  3. Select One record.
  4. Choose Task as the object.
  5. Set these field values:
Task fieldValue
SubjectDeal Review Required
WhatId/Related to ID{!recordId}
OwnerId/Assigned to ID{!Get_Current_Opportunity.OwnerId}
PriorityHigh
StatusNot Started

The WhatId/Related to ID field is the key setting. It connects the new Task to the Opportunity that started the Flow. In Salesforce, WhatId stores the related record for non-person objects, such as Accounts, Opportunities, Cases, and custom objects.

Create the Task Record for Opportunity in Salesforce Flow

If your Flow creates a related custom record instead, create a lookup field and map it to {!recordId}. You can learn the setup in this guide on how to create a lookup field in Salesforce Flow.

Activate and Add the Flow to the Record Page

  • Click Save and name the Flow – Create Deal Review Task.
  • Click Activate.
Create Deal Review Task in Salesforce
  • Go to Setup and open Object Manager.
  • Select Opportunity.
  • Open Lightning Record Pages.
  • Edit the relevant Opportunity record page.
  • Drag the Flow standard component onto the page.
  • Choose Create Deal Review Task.
  • Select Pass record ID into this variable.
  • Choose the recordId variable.
  • Save and activate the record page.
How to Pass a Record ID into Salesforce Flow

Open any Opportunity record and test the component. The Flow should display that Opportunity’s name and amount. If it shows blank details or cannot find the record, check the variable API name and confirm that Available for input is enabled.

Proof of Concept

As you open the Opportunity object and click the Next button, Salesforce Flow will automatically pick the currently opened opportunity record ID and create the task for the opportunity with values that you have provided in the screen flow.

Pass Record ID from Current Record Page to Salesforce Flows

How to Pass a Record ID into Salesforce Flow with a Quick Action

A Flow component works well when users need the process visible on the page. A quick action works better when you want a compact button, such as “Create Review Task,” “Request Discount Approval,” or “Escalate Case.”

Create the Flow Quick Action in Salesforce

  • Go to Setup and open Object Manager.
  • Select Opportunity.
  • Click Buttons, Links, and Actions.
  • Click New Action.
  • Select Flow as the Action Type.
  • Select your active Flow.
  • Enter Create Deal Review as the label.
  • Click Save.

Salesforce passes the current Opportunity ID to the recordId input variable when the action launches the Flow from the record page.

Add the Action to Page Layout in Salesforce

  1. In Object Manager, open Opportunity.
  2. Click Page Layouts.
  3. Edit the page layout used by your sales users.
  4. Find Salesforce Mobile and Lightning Experience Actions.
  5. Drag Create Deal Review into the action section.
  6. Click Save.

Users can now launch the Flow from the Opportunity’s action menu. This gives them a focused experience without placing a permanent Flow component on every record page.

You can use the same approach for a Case in Service Cloud. For example, pass a Case ID into a Flow, check its priority, create a related escalation task, and send an internal notification.

When a Flow might fail because of missing access or validation rules, always add fault paths in Salesforce Flow to show a useful error message or log the failure.

Pass a Record ID from a Custom Button or Link

Sometimes a quick action does not fit the user experience. For example, a team may use a custom button on a classic page layout, a Visualforce page, or a special Lightning component.

In that situation, create a URL that sends the record ID as an input parameter to the Flow. The input variable must still be marked Available for input.

A typical Flow URL pattern looks like this:

/flow/Flow_API_Name?recordId={!Opportunity.Id}

Replace Flow_API_Name with your Flow’s API name. Replace {!Opportunity.Id} with the merge field for the object where users click the button.

For an Opportunity Flow named Create_Deal_Review_Task, the button URL would look like this:

/flow/Create_Deal_Review_Task?recordId={!Opportunity.Id}

Use this method carefully. URL-based launches are useful for simple navigation, but quick actions and Lightning record page components are usually easier to maintain. If you want to explore the button approach in more detail, read how to call a Flow from a button in Salesforce.

Test the Flow Before Deployment

Testing matters because a Flow may work for an administrator but fail for a sales rep. I test this pattern with at least two users: an administrator and a standard user who will run the Flow daily.

  1. Open a test Opportunity with a known amount and owner.
  2. Launch the Flow from the record page or quick action.
  3. Confirm that the Opportunity name and amount display correctly.
  4. Complete the Flow and confirm that the Task appears in the Opportunity activity timeline.
  5. Test an Opportunity below the 50,000 threshold.
  6. Test a user with limited access to confirm that field and record permissions work as expected.

Use Debug in Flow Builder for basic logic testing. Then test the activated Flow from the actual record page because that is where Salesforce supplies the record context.

Things to Keep in Mind

  • Use the exact variable name: Name the input variable recordId and mark it Available for input. A typo or missing setting stops Salesforce from passing the current record.
  • Query only what you need: Use Get Records with the current ID, then reference only needed fields. This keeps the Flow easier to read and reduces unnecessary work.
  • Respect security: Users need access to the source record and any records the Flow creates or updates. Review Salesforce profiles and permission sets before releasing the Flow.
  • Avoid hard-coded IDs: Do not place a specific user, queue, record type, or record ID directly in production logic. Use fields, custom metadata, or configurable resources instead.
  • Add fault handling: Attach fault paths to Create Records, Update Records, and actions that may fail. A clear error message saves users from guessing what happened.
  • Test each launch method: A Flow embedded on a page, launched through a quick action, and opened by a URL may behave differently. Test the exact method your users will use.

Frequently Asked Questions

How do I get the current record ID in Salesforce Flow?

Create a Text variable named recordId and select Available for input. When you launch the Flow from a supported record context, Salesforce sends the current record ID into that variable.

Why is my recordId variable blank in Flow?

The variable may not have Available for input selected, or the API name may not be exactly recordId. Also confirm that users launch the Flow from a record page, record action, or button that passes the parameter.

Can I pass a record ID to an Autolaunched Flow?

Yes. Another Flow, Apex class, Process Builder migration, or supported automation can pass an ID into an Autolaunched Flow. The receiving variable must be a Text variable available for input.

Can a Screen Flow update the record that launched it?

Yes. Use {!recordId} in an Update Records element and select the relevant object. You can then update fields on the current Account, Case, Opportunity, or custom object record.

Can I pass an Account ID and create a related Contact?

Yes. Receive the Account ID in recordId, then use Create Records to create a Contact. Map the Contact’s AccountId field to {!recordId}.

Should I use a quick action or a Flow component?

Use a quick action when users should start the Flow on demand from a button. Use a Flow component when users need the Flow visible on the record page or use it repeatedly while reviewing record details.

Conclusion

Passing a record ID into Salesforce Flow lets your automation work with the exact record a user is viewing, which makes every process faster and more accurate. Start with a simple recordId variable, test the Flow with real user access, and add more logic only after the core process works. I hope you found this article helpful.

You May Also Like

live webinar

Build Your First Agentforce AI Agent in Salesforce

We will show demo on the complete process of building your first AI Agent in Salesforce using Agentforce. You’ll learn how agents work and how to connect your agent to Salesforce data to deliver intelligent business outcomes.

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.