+ Start a Discussion
salesforce codersalesforce coder 

How to pass recordId from Quick Action to flows

On the Opportunity record I have a quick action to create Contact roles. When I click on the quick action , I am opening a flow screen. And on that screen I need to prepopulate the Opportunity Id from where I came . What is the way ? 

I created a variable called recordID and set the type as input. Foe some reason that is not working. Any help ??
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan

You can set that using design attributes on the component you are embedding in the flow, say if you create an attribute to take the recordId and give design attribute for it
<design:attribute name="oppFieldValue" label="Opp Field Value"/>
<aura:attribute name="oppFieldValue" type="String" description="Value of the opportunity field to be populated." access="global"/>
Then on your flow screen in the 'Field Settings' tab bind the "Opp Field Value"  to the variable you have created "{!recordId}" 

If in your inputField if your value is bound with {!v.oppFieldValue} then you should be able to get the Opp Id in it.

Please let me know if you have any issues

Rich SimardRich Simard
While the above answer is a great one for a Custom Lightning Component, the original question is in the specific context of the Quick Actions component. 

I, too, am having an issue with this. I have a Screen Flow that I want to execute from a Quick Action on the Case object.  While I have an "Input Only" variable on the Screen Flow for the Case ID, there is no place to pass in system-generated inputs to the Quick Action setup, so the record ID is never received and used by the flow.

The flow has system/global variables in it and one of the options is called {!$Flow.CurrentRecord} -- attempting to extend any properties off this "CurrentRecord" object to treat it like a SObject most definitely throws JS errors on the front-end when attempting to launch the flow.  
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi Rich,

If you want to send the recordId to the flow action from the case object please create an attribute named "recordId" (case sensitive) with input only or input and output as option. The recordId gets automatically set based on which object the flow action is called from https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_distribute_internal_action.htm please refer this.

If your flow is used in the app builder page the recordId can be set via the design attribute on the app builder please refer this https://success.salesforce.com/answers?id=9063A000000id3jQAA

Please let me know if you have any issues.

Rich SimardRich Simard
Right you are! Thank you for the perfect solution.

I believe this is also what the original requester needed.  The input flow variable `recordId` is case sensitive -- the original poster listed the varaible name as `recordID`
Jeremy Evans 9Jeremy Evans 9

I'm having issues getting this to work, hoping someone can give guidance. I've created my variable and made it case sensitve recordId. Based on Salesforce guidance I don't even need to make a "Get Records" (or "record lookup" in classic) per this article https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_distribute_internal_action.htm

When I get to my record creation I have a master-detail lookup field I need to populate to tell the system hey, this new record we're creating is a child of the record we executed the action on, but when I get to the end of my flow I keep getting an error and in the report it says the required field (the master-details field) is missing. I've verified that my variable is case sensitive and I've verified that the record creation has a line to update the master-detail field with the recordId variable. 

I also tried making a "Get record" element as the first step. I made the criteria id = recordId and didn't assign any fields as a resource, still didn't work. Then went back and in the "Get Record" element I assigned the "ID" as a resource called MasterRecordId and then updated my record creation screen to update the master-detail with this new MasterRecordID variable but that isn't working either. Not sure what I'm missing but any guidance is appreciated.

Megan D MoodyMegan D Moody
I'm having trouble getting this to work as well. To simply things, I created a test flow that just has a screen displaying the input variable recordId. In the utility bar, I added the flow and passed in {!Record.Id} (which is the same syntax used when my pass the current record's ID to a flow in a lightning page). 

I've opened a case with Salesforce and will update here if I get a solution to this. However, I thought I'd also see if anyone has more information on this since the last post? 
Yogesh BiyaniYogesh Biyani
I too would like to know how to do this.
Rich FiekowskyRich Fiekowsky
I too find that despite the documentation, the variable recordId , case-sensitive, input-enabled, equals null when my Flow is launched by a Lightning Action that is in the Record Page of an Opportunity. Also, it seems very odd to name it recordId when the value is said to be a record, not an ID (string). I tested making the variable's data type "text" instead, but it remains null.
Hey everyone. I came across this article in my research to fix a similar issue of wanting to launch a screen flow from a Quick Action on a custom object. I was able to solve my issue by applying the recordId text variable as mentioned above. I noticed a few still had issues so wanted to outline my process: 

At the beginning of my flow I ran a GetRecord where the ID matched my text variable labeled "recordId" (case sensitive). Per this article (https://help.salesforce.com/articleView?id=flow_actions_considerations.htm&type=5), that is correct way to pass the variable from the Quick Action into the Flow. The GetRecord may not have been necessary but I wanted to use variables from that record for other areas of the screen flow. 

Below is my GetRecord Element screen

User-added image

Hopefully that helped sort it out!
Eric Blaxton 11Eric Blaxton 11
@mattd  That worked like a charm.  Thanks for posting this.