I have a child Aura component that implements the "force:hasRecordId" interface.

I want to use a recordId passed into the child component by a parent Aura component. I do not want the child component to use the recordId of the page that the components are placed on.

Looking at the attached photos, when the child component accesses the recordId variable using component.get("v.recordId") I want it to be "exampleId"

Child: enter image description here

Parent: enter image description here

1 Answer 1


There is a small typo in your code:

  • For passing data from parent to child using an attribute we need to use syntax - {!v.exampleId}

I tried this scenario and below is the working code for the same.

Parent Markup : Here , we declare an attribute named exampleId of type String and pass to the child component.

<aura:component implements="lightning:isUrlAddressable,flexipage:availableForAllPageTypes" >
  <aura:attribute  name="exampleId" type="String" default="abc"/>
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" description="Handler for valueInit event fired when the component has been initialised"/>

  <c:attributeChild recordId="{!v.exampleId}"></c:attributeChild>

Child Markup:

<aura:component implements="force:hasRecordId" access="global">
  <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    Record Id in child : {!v.recordId}

In the UI you would see value of exampleId : enter image description here

But I would advise you to rename it with something else since it will create confusion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .