I built an application with Lightning Experience. In my custom apex controller, I have a method named getParam.

public class compController {
  public static List<ObjectParent> getParam (Id master) {
    List<ObjectParent__c> objList = [SELECT ID, Name, (SELECT ID, textField1__c, checkBox1__c FROM Child__r] FROM ObjectParent WHERE MasterID__c =: master];
    return objList;

Lightning Component

        <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
          <aura:attribute name="listObjectParent" type="ObjectParent" />
          <aura:attribute name="master" type="String" default="1231242112341" /> 
            <aura:iteration items="{!v.listObjectParent}" var="objdata" 

JS Client Side Controller

doInit : function(component, event, helper) {
        var action = component.get("c.getParam");
        var master = component.get("v.master");
        action.setParams({"master" : master});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(component.isValid() && state === "SUCCESS"){
                var listObjectParent = response.getReturnValue();
                component.set("v.listObjectParent", listObjectParent);
                console.log("Failed with state: " + state);

I need to initialize this with js client side controller at the component. I understand the output is a list in the list, which looks like:

  1. parent ID, parent name, ["ID","1234" ,"textField1__c", "xx1", "checkBox1", "true"]
  2. parent ID, parent name, ["ID","3456" ,"textField1__c", "xx2", "checkBox1", "false"]
  • 2
    Where exactly are you stuck?
    – Adrian Larson
    Commented Apr 14, 2017 at 12:09
  • I updated post. I think - my JS controller is not correct.
    – John
    Commented Apr 14, 2017 at 12:35

2 Answers 2


The issue here is that you are getting value from Apex is a list and you are using an object attribute instead of list object:

<aura:attribute name="listObjectParent" type="ObjectParent" />

Should be:

<aura:attribute name="listObjectParent" type="ObjectParent[]" />
  • I correct this earlier.
    – John
    Commented Apr 14, 2017 at 13:05
  • Ohh, you forgot to update in the question. Commented Apr 14, 2017 at 13:19

If you are using this in markup you can use aura:iteration to iterate through it a get the values.

Let's say the aura attribute in client side is objParentdata:

  <aura:iteration items="{!v.objParentdata}" var="objdata" indexVar="index">
  • I updated post. I know that I should use aura iteration but I think - i doing something wrong.
    – John
    Commented Apr 14, 2017 at 12:34
  • Can you do a console.log(JSON.stringify(listObjectParent)) of var listObjectParent.I think the way you are accessing variables must be where the issue is
    – RedDevil
    Commented Apr 14, 2017 at 12:45
  • So, I get correct info but I don't know how I should iterate for this. [{"Id":"a0A46000001ycBzEAI","Name":"imię?","Child__r":[{"Question__c":"a0A46123401ycBzEAI","Id":"a0B46123400X5ZGEA0","checkBox1__c":true,"textField1__c":"xd1"},{"Question__c":"a0A46123401ycBzEAI","Id":"a0B46123400X5ZCEA0","checkBox1__c":false,"textField1__c":"xd2"},{"Question__c":"a0A46123401ycBzEAI","Id":"a0B46123400X5ZLEA0","checkBox1__c":true,"textField1__c":"xd3"}]}]
    – John
    Commented Apr 14, 2017 at 12:56
  • <aura:iteration items="{!v.listObjectParent}" var="objdata" indexVar="index"> <p>{!objdata.Name}</p> <aura:iteration items="{!objdata.Child__r}" var="childqdata" indexVar="index1"> <p>{!childqdata.checkBox1__c}</p> </aura:iteration> </aura:iteration> </aura:component> try this out
    – RedDevil
    Commented Apr 14, 2017 at 13:21
  • you have a child list inside a parent so you need an aura iteration inside another
    – RedDevil
    Commented Apr 14, 2017 at 13:30

You must log in to answer this question.

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