I am trying to pass an attribute from parent component to child component. But the catch is this attribute is populated in apex controller using wrapper class. So currently it is a list of wrapper object. But when I am trying to pass this attribute to child component, on console log of child client controller it is showing undefined.

Parent Apex Class:

public static List<dataWrapper> getParentDetails(String RecordId){
        list<dataWrapper> lstwrpParent = new List<dataWrapper>();
//doing some query and adding to the list
return lstwrpParent 

public class dataWrapper{
        public Id childRecordId{get;set;}
        public String childName{get;set;}
        public String recordTypeName{get;set;}
        public dataWrapper(Id childRecordId,String childName,String recordTypeName){

Parent Controller:

// setting the lstwrpParent response from apex class to v.parentrecordlist

Parent Component:

<aura:attribute name="parentrecordlist" type="Object"/>
<lightning:card title="">
      <c:ChildComponent parentData="{!parentrecordlist}" />

Child Component:

<aura:attribute name="parentData" type="Object"/>

Child js Controller:

var test1= component.get("v.parentData");
console.log("parentData "+ test1 );

1 Answer 1


make sure check in Server call response your getting the response or not there, and then like on Success of your server call add this line before assigning to "parentrecordlist" variable.

if(state === "SUCCESS"){
 console.log('data:',response.getReturnValue());// check if here data coming

then Change the attribute from type:

<aura:attribute name="parentData" type="Object"/>


<aura:attribute name="parentData" type="yourclassName.dataWrapper[]" />
  • yes, server call is returning values. checked using console.log("parent " + JSON.stringify(response.getReturnValue())); Even replacing type to list is showing undefined in child js controller console log
    – Akash
    Dec 17, 2020 at 5:28
  • we are good there, did you try changing the attribute type?
    – Umesh Beti
    Dec 17, 2020 at 5:30
  • yes changed the attribute type to list from object still undefined.
    – Akash
    Dec 17, 2020 at 5:31
  • i have updated my answer check now!
    – Umesh Beti
    Dec 17, 2020 at 5:34
  • tried your yourclassName.dataWrapper[] approach but still undefined. made changes in both parent and child component aura attribute type
    – Akash
    Dec 17, 2020 at 5:42

You must log in to answer this question.

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