The below code will add only the record type of “Contact” object accessible to the user.
List <SelectOption> rtList = new List <SelectOption>();
for (RecordTypeInfo rtInfo: Contact.SObjectType.getDescribe().getRecordTypeInfos() ) {
if(rtInfo.isAvailable()) {
rtList.add(new SelectOption(rtInfo.getRecordTypeId(), rtInfo.getName()));
}
}
Apex Controller:
Create below apex controller to get the inner SOQL query data.
public with sharing class AuraSampleController{
@AuraEnabled
public static List<Account> getAccounts() {
List <Account> accList = [SELECT Name, Type, Industry, (SELECT FirstName, LastName From contacts) From Account LIMIT 5];
return accList;
}
}
Sample Lightning Component:
Create below lightning component Sample.cmp for display the inner SOQL query data on component.
({
doInit: function(component, event, helper) {
//Call apex class method
var action = component.get('c.getAccounts');
action.setCallback(this, function(response) {
//Get state of response
var state = response.getState();
if (state === "SUCCESS") {
//Set result in accList attribute on component.
component.set('v.accList', response.getReturnValue());
}
});
$A.enqueueAction(action);
}
})