I am trying to fetch AccountContactRelation recordsrelated to specific accountId from Lightning component via server side call. I am passing the AccountId as a param to the apex controller. But unfortunately the query returns null. Any help would be appreciated. Here is the code of the apex controller class:
doInit : function(cmp, event, helper) {
console.log('v.recordId----------->'+cmp.get("v.ClientId"));
var action = cmp.get('c.getrecs);
action.setParams({"AccountId": cmp.get("v.ClientId")});
action.setCallback(this, $A.getCallback(function (response) {
var state = response.getState();
if (state === "SUCCESS") {
cmp.set('v.acrrecords', response.getReturnValue());
}
else if (state === "ERROR") {
}
}));
$A.enqueueAction(action);
}
@Auraenabled
public static list<AccountContactRelation> getrecs(String AccountId){
list<AccountContactRelation> acr = [select id,AccountId from AccountContactRelation where AccountId =:AccountId ];
return acr;
}
Thanks!
with sharing
orwithout sharing
? – David Reed♦ May 1 '18 at 20:26