May 27, 2020

How to pass record Id in Flow to Lightning Component in Salesforce?

Aura Component Code:
FlowComponent.cmp:
<aura:component implements="lightning:availableForFlowScreens">    
    <aura:attribute name="RecordId" type="String"/>    
    <lightning:recordViewForm recordId="{! v.RecordId }" objectApiName="Account">
        <div class="slds-box">
            <lightning:outputField fieldName="Name" />
            <lightning:outputField fieldName="Industry" />
        </div>
    </lightning:recordViewForm>    
</aura:component>


FlowComponent.design:
<design:component>
<design:attribute name="RecordId" label="Record Id" required="true"/>
</design:component>

Flow:


Input Variable for capturing record id:


Pass RecordId which is the Input Variable:


Output:



5 comments:

  1. Hello,

    I am trying to pass a record id from the flow to lightning component (which is added to the flow) but I don't see an option to pass the record id. I added to the lightning component.

    In your screenshot above I see you have the "Record Id" in the sample flow but I don't get that option. Please help.

    ReplyDelete
  2. I had the same problem and was able to figure it out with some help. You need to include the record id in the ".design" file as a design:attribute to make it available on the flow.

    ReplyDelete
  3. Same, I added this to the .Design, the it worked just fine.



    ReplyDelete