0

I am using lightning tree grid aura component. I am trying to grab a few field values from the Account object inside _children. This is what I have so far(from another thread) cant find the link. The AccBilling should be populated in each row inside the grid but currently its only getting the parent level. How do I traverse inside the children object and get the Account BillingStreet from there?

if (state === "SUCCESS") {
                var data = response.getReturnValue();
                //Change "AccountContactRelations" key to "_children"
                for(var i=0; i<data.length; i++) {
                    data[i]._children = data[i]['AccountContactRelations'];
                     //fetch the data related to Account
                     var accData = data[i]['Account'];
                     //get data for specific data
                     data[i].AccBilling = accData.BillingStreet;
                    delete data[i].AccountContactRelations;


            }

Here is my return result:

[
   {
      "Id":"003f000001OP7trAAD",
      "AccountId":"001f000001POxdiAAD",
      "Is_Referrable__c":true,
      "Name":"Adrian Lo",
      "MailingAddress":{
         "country":"United States",
         "countryCode":"US"
      },
      "Account_Name__c":"Adrian Lo, MD, FRCS, FACS",
      "Account":{
         "BillingStreet":"4524 Rising Sun Avenue",
         "Name":"Adrian Lo, MD, FRCS, FACS",
         "Phone":"XXX-XXX-6900",
         "Id":"001f000001POxdiAAD"
      },
      "_children":[
         {
            "ContactId":"003f000001OP7trAAD",
            "Id":"07kf000000AvE1SAAV",
            "AccountId":"001f000001POxc7AAD",
            "Account":{
               "BillingStreet":"2104 Test Street",
               "Name":"Test Account",
               "Id":"001f000001POxc7AAD"
            }
         },
         {
            "ContactId":"003f000001OP7trAAD",
            "Id":"07kf000000Av2hnAAB",
            "AccountId":"001f000001POxdiAAD",
            "Account":{
               "BillingStreet":"4524 Rising Sun Avenue",
               "Name":"Adrian Lo, MD, FRCS, FACS",
               "Id":"001f000001POxdiAAD"
            }
         }
      ],
      "AccBilling":"4524 Rising Sun Avenue"
   },

]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.