Flow: How To Use Record Id

flow record Id

If you have tried to build a record-specific flow, then you must have heard of building input variables and feed the record Id in. During the Salesforce releases in 2020, there are more intuitive ways to achieve this by using “RecordId” variable.

ComparisonCustom Input Variable“recordId” Variable
What variable to createA variable:
with any name,
with Type = Record or Text,
allows for input.
A variable:
with name = recordId (Case sensitive),
with type = Record,
allows for input.
Where can this be used– Custom button
– Lightning app builder
– Custom button
– Lightning app builder
– Custom action
– Record-triggered flow
Main Difference:
  • Only recordId Supports Quick Action and Record-Triggered Flows:
    Once you create a recordId variable, Record Id will automatically be captured in a quick action, so you do not need to assign the Id as we do in a button. If you are creating a record-trigger flow, you do not even need to create that variable. (see point 4 for details)


  • Only Custom Variable Supports Both Record and Text Type:
    Here we are only focusing on feeding “Record’s Id into variables”. You can either feed the Id into a record variable, or into a text variable. For the latter, you will need to create a “Get Records” element to get other fields.

Why using Text type if another element is needed:
When you store the Id into a record variable, the system will retrieve all the fields from that specific record. The more fields you have, the more time it takes for the flow to run. If you wish to only get a few of the fields into your flow, I would recommend using the text type.

Let’s see how to use these two types of variables in each of the places:

1. Custom Button
Custom Input Variable“recordId” Variable
Applicable?
How ToCreate a new detail page button, paste flow url, and add “?[Variable name] = Id

Example: /flow/update?CustomName={!Account.Id}

Same as the left.


Example: /flow/update?recordId={!Account.Id}
2. Lightning App Builder

*** Note: Only Screen Flow can be put on a Lightning page.

Custom Input Variable“recordId” Variable
Applicable?
How ToEdit Lightning page, add a flow component, and check the box under the variable.

Same as the left.

3. Custom Action
Custom Input Variable“recordId” Variable
Applicable?
How ToNot Applicable.Simply create a new action, pick Flow as action type, and choose the correct flow.
4. Record-Triggered Flow
Custom Input Variable“recordId” Variable
Applicable?
How ToNot Applicable.Create a record-triggered flow and assign the object, and then you will have the $Record variable by default.

Summary

Applicable?Custom Input Variable“recordId” Variable
Custom Button
Lightning App Builder
Custom Action
Record-Triggered Flow
Required to create variable?Custom Input Variable“recordId” Variable
Custom Button
Lightning App Builder
Custom ActionN/A
Record-Triggered FlowN/A
Check Out How Record Id Can Be Used In Real Cases!
Use Case: Use Flow To Auto Close The Spam Case
Spam is like a never-ending fight, especially for marketing and ...
Use Case: An Easy Flow To Copy Address Field
This is just an easy example to illustrate the concept ...
Use Case: Create Parent and Child Cases in One Flow
Do you need to create a Screen flow that allows ...
Use Case: Replace “New” Button with Screen Flow
Currently we can only overwrite the New button using programmatic ...
Loading...

Official Salesforce Help Article On Record ID

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Laura

Thank you very much for this information. It was helpful.