I have an action that returns a list of Account objects. Account object has a custom object field called Support__c that I want to get the name of the Support__c instead of getting the objectID. So, I am calling getSupport within getAccounts's callback. I am debugging the getAccount function, but it is not called (does not log anything).
Code:
.js
action_get_accounts.setCallback(this, function(data) {
var returnedObject = data.getReturnValue();
for (i = 0; i<returnedObject.length; i++) {
//Prints here
var action_get_support_name = component.get("c.getSupport");
action_get_support_name({suportId: cvs['Support__c']});
action_get_support_name.setCallback(this, function(data) {
returnedObject[i]['Account__c'] = date.getReturnValue();
});
$A.enqueueAction(action_get_account_name);
}
}
$A.enqueueAction(action_get_accounts);
.apxc
@AuraEnabled
public static String getSupportName(Id supportId) {
System.debug('function called'); //does not print here
Support__c support =[Select Name FROM Support__c WHERE id = :supportId];
return support.Name;
}