May 27, 2020

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

Aura Component Code:

<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>


Flow:


Input Variable for capturing record id:


Pass RecordId which is the Input Variable:


Output:



3 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
    Replies
    1. Create a input variable in the flow.
      Use in the Component.

      Delete
  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