function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mark RutterMark Rutter 

How to get the current record ID in a Flow?

I want to initiate a Flow from a button on a Custom Object.  How do I capture the ID of that Custom Object record and be able to use it in the Flow?
Best Answer chosen by Mark Rutter
Mark RutterMark Rutter
First dreate a Flow Variable linked to an SObject.  You do this by selecting SObject variable from the Default Value selection box.  Data type as Text and Input/Output Type as Input and Output.

Then  the URL on the custom button will look like: /flow/Get_Inquiry?InquiryID={!Inquiry__c.Id}

All Answers

Mark RutterMark Rutter
First dreate a Flow Variable linked to an SObject.  You do this by selecting SObject variable from the Default Value selection box.  Data type as Text and Input/Output Type as Input and Output.

Then  the URL on the custom button will look like: /flow/Get_Inquiry?InquiryID={!Inquiry__c.Id}
This was selected as the best answer
Clayton Thomas 6Clayton Thomas 6
I have a similar question, but we are using Lightning (so javascript buttons are not an option) so I wanted to conduct the flow interview in a lightning component on the page, but again, how can I obtain the record id from the page I'm on and use it in the flow??

I'm trying to set up this flow to look through all related records of a certain type and loop through each, allowing the end user to evaluate each record and make a quick update to it before moving on to the next. I think this should be possible, but I believe the first step is just getting the id from the record I'm on before I can identify records related to it. 
Mike McCann 8Mike McCann 8
Clayton Thomas 6, did you find a solution to this?
Jordan StoffelJordan Stoffel

Piggybacking to make life easier for the next person who searches for this (like me):
If you create a flow action, and make sure your flow has a text input named "recordId", the starting record Id will be picked up automatically. 
Source: https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_distribute_internal_action.htm

Line Maria Eiler 6Line Maria Eiler 6
Jordan Stoffel, thank you so much for sharing! This could have kept me up all night. 
Sudheer A 4Sudheer A 4
Thanks Jordan


 
William Jesse RobertsonWilliam Jesse Robertson
Thank you Jordan!
Boris Todorov GichevBoris Todorov Gichev
Thank you Jordan!
Mark Kh09Mark Kh09
Jordan wins first prize.  Thank you for saving me hours of my time.
Tony van StratenTony van Straten
TANKS JORDAN.

Why in the hell isnt that already DEFAULT does Saleforce expect you to always remember that.

FIX IT SAlesforce
Troy CenterTroy Center
@Mark Rutter. Asked and answered your own question. Thanks for that. I needed this in 2020!. Troy 
sofiya merisofiya meri
Nice Article and Thanks for Share New Ideas. website (https://mycfavisit.xyz/)
Pedro Diezhandino 16Pedro Diezhandino 16
Hello!

 Thanks to all for sharing, apparently create a RecordID text input is only feasible on actions, but I have the requirement to do so in a screen flow.

Is there a way to pass current RecordID to a screen flow?

The used of guided process to complete the current record is so powerful that I am pretty sure there has to be a way.
 
Mark Kh09Mark Kh09
Create a new flow.  Add a text variable element called "recordId".  It will automatically pick up the id from the record from where the button/action was pressed.  In terms of how you get that button on the layout, create an action that points to the flow you created, go to the page layout (not LEX), "mobile & lightning actions", and then add it.  I hope that makes sense.
yogendra singh 53yogendra singh 53
Hello Every One I need to associate account id with opportunity 
I have created screen flow and to capture the account id i have created the Variable with API name recordId available for input.
I have debugged the Flow as well for which in input we have to manually pass the recordId and opportunity is getting associated with Account.
 In Account record page have associated this flow from there i am able to successully create the Opportunity but it is not getting associated with Account Id.
 Variable spelling and caps all are correct but still from UI it is not working
SAGAR BORADE 2SAGAR BORADE 2
Thanks Jordan !!
Rachel SchnappRachel Schnapp
Yogendra, you need to go to the Lightning Record Page where your screen flow is located, and then select your screen flow component. In the flow component's menu (right side of screen), populate the value of the recordId field by checking the box labeled "Pass record ID into this variable". 
Rebecca MorgensternRebecca Morgenstern
Hi,


From an opportunity the user is prompted to a screen flow with a propertylookup.
How can I get the opportunity recordID that started this flow?


I have a variable
recordId 
DataType Text
Both available for input / output are checked off.


however its always null. The error is when I'm trying to used the recordId value
ASSIGNMENT: Assign Opportunity Prop Values
{!varOpportunityProperty.Property__c} Equals {!lkupProperty.selectedRecordId}
{!varOpportunityProperty.Opportunity__c} Equals {!recordId}
Result
{!varOpportunityProperty.Property__c} = "a084x000004w8GkAAI"
{!varOpportunityProperty.Opportunity__c} = "null"


Thank you in advance for your help








 
Boris Todorov GichevBoris Todorov Gichev

Hi Rabecca,

I am nit sure what is the issue, please provide a picture whit the flow and the declaration of the recordId.

A few things to check that would prbably help you solve the issue.

1. The name "recordId" is case sensitive and if it is not wriiten exacltly the way SF sugests it, it will not work
2. Remove the available for output check
3. On the first screen of the flow put the recordId somewhere to be visible, so you can debug in real time.
4. If none of this works click on edit page and put the flow directly on the page, where you can setup the record id as a setting on the flow component on your page : https://help.salesforce.com/s/articleView?id=sf.flow_distribute_internal_lab.htm&type=5

For now this is all I can recomend.

Trevor Ali 7Trevor Ali 7
Thanks Jordan and Boris.  On Boris' list #1 and #2 got the trick done.
veerabhadragouda .veerabhadragouda .
There is button placed on account list view which calls a flow, it enables user to select multiple accounts and pass those id's to flow. now i have placed thais list view on 'Training'(custom object) record page i want to pass training record id to the flow which triggers on click of button in account list view. can anyone help me ho wto pass training record id to flow? requirement is to add multiple accounts to training after selecting multiple account and clicking button we create 'training attendees' (acts like junction object)records for those accounts for that training.
Troy CenterTroy Center

@veerabhadragouda, I'm the one who flagged this post as inappropriate. The most basic function of flow is to call it from a button. This response was posted 5 years ago: https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8hH0SAJ

As with most forums, please do some homework on very basic questions before posting to the forum (at least google it). Additionally, this question is not related to your question and thus also not appropriate. Try to find the right questions to add responses to. Thanks for asking! Just a little ettiquette. We love to help. See the link above. Troy