Skip to main content
New tool CRON Expression Builder — preview next run times before you schedule Apex. Open the builder →
Diagram showing data passing from a Salesforce record page into a Screen Flow using the recordId variable.
Flow

Passing recordId and record data into a Salesforce Screen Flow — how and best practices | Salesforce Flow recordId

The short answer

To pass the current record ID into a Salesforce Screen Flow, create a text variable named `recordId` and mark it as available for input. Lightning record pages, Quick Actions, URL parameters and Lightning Web Components can then hand the flow that ID, which the flow uses to query the data it needs.

Key takeaways Create a flow variable with the API Name recordId, spelled exactly that way because it is case-sensitive, with the data type set to Text and Available for input checked. Tick the Pass record ID into this variable checkbox when you add the Flow component to a Lightning record page in Lightning App Builder. Launch a screen flow from a Quick Action and Salesforce passes the record ID for you, with no parameter mapping to set up. Pass the record ID alone and fetch the fields you need with a Get Records element inside the flow, which respects Field-Level Security better and is easier to debug.

How to pass the Salesforce Flow recordId into a Screen Flow

You're building a screen flow to sit on an Opportunity page, and it needs to know which Opportunity it's looking at. That is what the Salesforce Flow recordId variable is for. It's one of those day-one skills for any admin or dev, but there are a few ways to handle it that aren't always obvious if you're just starting out.

The core idea is simple. You tell the flow the ID of the record the user is currently looking at, and once the flow has that ID, you can use a Get Records element to pull in any other field you need. In my experience, this is much cleaner than trying to shove every single field into the flow at once.

How to set up your Salesforce Flow recordId variable

Before you do anything else, you have to create the variable inside the Flow Builder, and you have to name it exactly right. If you don't, Salesforce won't know where to put the data. I've seen plenty of people waste an hour debugging just because the capitalization was off or a box was left unchecked.

  • API Name: recordId (it must be case-sensitive, all one word).
  • Data Type: Text.
  • Availability: check the box for "Available for input".

That "Available for input" part is vital. If you leave it unchecked, the flow is basically a locked room, and Salesforce can't drop the ID inside. Once that's set up, you have a few ways to actually use it.

1) Dropping the flow on a Lightning record page

This is probably the most common way I use flows. You open the Lightning App Builder, drag the Flow component onto the page, and select your flow. If you named your variable recordId and set it as an input, you'll see a checkbox that says "Pass record ID into this variable." Check it, and you're done. Salesforce handles the rest.

The Salesforce Lightning App Builder properties panel, showing the setting that passes a record ID into a flow.

The Salesforce Lightning App Builder properties panel, showing the setting that passes a record ID into a flow.

2) Using Quick Actions

If you want your flow to pop up in a modal when a user clicks a button, you'll use a Quick Action. When you create a new action and choose "Flow" as the type, Salesforce is smart enough to look for that recordId variable. It passes the ID automatically. It's a good way to keep the UI clean while still giving users the tools they need.

3) Custom URL buttons

Sometimes you're working in a more custom environment, or even in Classic. In those cases, you might launch a flow via a URL. You just append the variable to the end of the URL like this:

/flow/Your_Flow_Name?recordId={!Account.Id}

But honestly, I try to avoid this unless I really have to. Hardcoding URLs can get messy when you're moving between sandboxes and production.

Passing the full record vs. the Salesforce Flow recordId

I get asked this a lot: can you pass the whole record instead of just the ID? You can, and you probably shouldn't. You can create a Record variable and set it to "Available for input," but this only really works well when you're launching a flow from Apex or a Lightning Web Component. If you're using the standard page builder, Salesforce is only going to give you the ID.

Pro tip: Always prefer passing the ID and using a Get Records element. It's more flexible, it respects Field Level Security better, and it makes your flow much easier to debug when things go sideways.

When you fetch the data inside the flow, you're in control. You decide exactly which fields you need. If you try to pass a full record from an LWC, you have to make sure every single field matches the flow's expectations. It's a lot of extra work for very little gain. If you're trying to decide between the two, check out this guide on Apex vs Flow to see where the boundaries are.

A code editor showing the JavaScript that initializes a Salesforce flow inside a custom component.

A code editor showing the JavaScript that initializes a Salesforce flow inside a custom component.

Handling data in LWC or Aura

If you're a developer building a custom UI, you might need to start a screen flow from code. You'll use the lightning-flow component in LWC. Here's what that looks like in your JavaScript:

const inputVariables = [
  { name: 'recordId', type: 'String', value: this.recordId }
];

It's straightforward, but again, make sure that name matches your flow variable exactly. I've seen teams get this wrong when they're rushing to hit a sprint deadline, and it's a pain to track down later.

Key takeaways for Salesforce Flow recordId

  • Naming matters: always use recordId with a lowercase 'r' and a capital 'I'.
  • Enable input: your variable must be "Available for input" or it won't work.
  • Get Records is your friend: pass the ID, then query the data you need inside the flow.
  • Security first: flows usually run in the user context, so they'll only see what that user has permission to see.

Following these steps will save you a lot of headaches. If you're looking for more ways to keep your automation clean, read up on Salesforce Flow best practices. It'll help you build things that don't break the moment another admin touches them.

So, the next time you're setting up a screen flow, stick to the recordId pattern. It's the standard for a reason: it's reliable, it's easy to teach to junior admins, and it works across almost every part of the platform.

Frequently asked questions

How do you configure the recordId variable in Salesforce Flow?

Create a variable resource in Flow Builder with the API Name `recordId`, spelled exactly that way because it is case-sensitive, set the Data Type to Text, and check the Available for input checkbox.

How do you pass recordId to a screen flow from a Lightning record page?

Add the Flow component to the page layout in Lightning App Builder, choose your flow, and tick the checkbox labeled Pass record ID into this variable.

Should you pass the full record or just the recordId into a Flow?

Pass the record ID alone and query the fields you need with a Get Records element. That is more flexible, it respects Field-Level Security, and it makes troubleshooting easier.

How do you pass recordId into a screen flow from an LWC?

Embed the flow using the `lightning-flow` component and define an input variable array in JavaScript with `{ name: 'recordId', type: 'String', value: this.recordId }`.

Newsletter

One email every Tuesday

New guides, tool updates, and the release-note changes that break things.

No spam. Unsubscribe in one click.

Comments

Loading comments...

Leave a Comment