+ 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
Hi,

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

Thanks,
Ashwin
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.

Thanks,
Ashwin
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.