
public with sharing class CustomerLifeTimeController {
public with sharing class Itinerary{
String ItineraryRef;
}
@AuraEnabled
public static List<Object> getRelatedItineraries (Id recordId) {
List<Itinerary> itins = new List<Itinerary>();
Itinerary itin = new Itinerary();
itin.ItineraryRef = 'Itinerary 1';
itins.Add(itin);
return itins;
}
}
({
doInit : function(component, event, helper) {
var action = component.get("c.getRelatedItineraries");
action.setParams({
recordId: component.get("v.recordId")
});
action.setCallback(this, function(response){
var relatedItins = response.getReturnValue();
component.set("v.relatedItineraries", relatedItins);
});
$A.enqueueAction(action);
}
}
)
Any help gratefully received! Note that if i change the APEX to return a list of Opportunities (and use a read field name in the aura component) it works fine, so I'm fairly sure the javaScript is wired up ok - I'm just misunderstanding someelse somewhere!Thanks<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="CustomerLifeTimeController">
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="relatedItineraries" type="Object" />
<aura:attribute name="opportunity" type="Object" />
<aura:attribute name="remoteRecordId" type="Id" />
<aura:attribute name="showDialog" type="String" default="false" />
<force:recordData aura:id="relatedPropertyService"
recordId="{!v.recordId}"
targetRecord="{!v.opportunity}"
recordUpdated="{!c.doInit}"
layoutType="FULL" />
<lightning:card iconName="custom:custom84" title="Related Itineraries">
Info<br/>
<aura:iteration items="{!v.relatedItineraries}" var="item" indexVar="i">
Item : {!item.Itinerary}
</aura:iteration>
</lightning:card>
</aura:component>

Hi BothI have figured out the issue - and it was actually neithrer of the above; Hemant_Soni - you can't change to sObject because you can't convert Itinerary object to that. Alain - the Lightning Data Service works with custom objects - and the init is already wired up (proven because Aura Iteration was working ok).The actual problem was that in my custom object, the property ItineraryRef was not declared as public, and did not have the @AuraEnabled attribute. As soon as I did this, data appears ok!for example it needed to be this: public with sharing class Itinerary{
@AuraEnabled
public String ItineraryRef;
}