SOQL

How to show data from inner SOQL Query in lightning component.

Lightning Component
Prerequisites : basic understanding of Lightning Component and apex programming

This sample code shows that how we can show data from inner SOQL query in lightning component.

In this sample code, we will fetch List of accounts with there related contacts and display it on lightning component by using aura:iteration. tag

apex class [accWithContController.apxc]

component [sample.cmp]

  • For display related contacts of account we are using nested aura:iteration.
  • In the nested aura:iteration we use list of contacts of a single account (which store in acc variable).

controller [sampleController.js]

TestApp.app

output -:

SOQL
Like our facebook page for new post updates.?

(Visited 6,824 times, 1 visits today)

4 comments

  • This page has an error. You might just need to refresh it. Error in $A.getCallback() [repsonse is not defined] Callback failed: apex://test_acc_dev.AccountDetailController/ACTION$fetchAccount Failing descriptor: {markup://test_acc_dev:AccountDetails}

    Note:My Controller name is different here

     

    I’am getting this error.How should I resolve this ?

  • This is great seeing examples like this. I am looking for something very similar but alas its not the same whereby I can just use this as the template. I have a appointment screen where staff back booking against a client’s support contract (covers a year), and the contract has a number of different services on it. We use lightning format and unfortunately with that lookup fields dont just drop down to show the entire filtered lookup list. You have to type in the first 5 characters before the value (service) appears so it can be selected. This is a real pain and what I wanted to do for users is to have a component out to the right that lists the services that are on the contract, to make it easy for them to know what to type.

    The contract is a lookup field back on the appointment. It is not able to be used in a related list and even if it was we need to display the next level down (the service child records).

    Something like this where I can write the appropriate soql would be ideal, but I would need to be able to reference the service agreement id (contract) back on the appointment record in the Details tab to the right to have the just the relevant service records filtered for display. I have seen some examples on referring to current record in apex. Is this easy to adapt your code above for.

     

Leave a Reply