I have an aura component with a lightning card and lightning record form inside the lightnign card. I have the init handler which calls the doinit controller which calls the helper:
doinit : function(component, event, helper) {
helper.checkToDisplayComponentClient(component);
helper.getAllProductFieldsClient(component);
}
getAllProductFieldsClient : function(component) {
this.getProductSpecificFieldsClient(component);
}
Initially in getProductSpecificFieldsClient
I was calling getProductCommonFieldsClient
:
getProductSpecificFieldsClient : function(component) {
var action = component.get("c.getProductSpecificFields");
action.setParams({oppId : component.get("v.recordId")});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
component.set("v.productFields", response.getReturnValue());
this.getProductCommonFieldsClient(component);
} else if(state === "ERROR") {
component.set("v.productFields", "");
component.set("v.commonProductFields", "");
}
});
$A.enqueueAction(action);
}
It was working for a month until now. Now, when I open an opportunity it was lightning cards under which common fields and specific fields should be displayed doesn't show anything.
If I move getProductCommonFieldsClient
out of getProductSpecificFieldsClient
and place it in getAllProductFieldsClient
it works (see below).
getAllProductFieldsClient : function(component) {
this.getProductCommonFieldsClient(component);
this.getProductSpecificFieldsClient(component);
}
- Why I do not understand.
If I modify getProductSpecificFieldsClient
including the lines var errors = response.getError(); console.log('state: products specific ' + errors[0].message);, like below:
getProductSpecificFieldsClient : function(component) {
var action = component.get("c.getProductSpecificFields");
action.setParams({oppId : component.get("v.recordId")});
action.setCallback(this, function(response) {
var state = response.getState();
console.log('state products specific ' + state);
var errors = response.getError();
console.log('state: products specific errors ' + errors[0].message);
if(state === "SUCCESS") {
console.log('state: products specific ' + response.getReturnValue());
component.set("v.productFields", response.getReturnValue());
} else if(state === "ERROR") {
component.set("v.productFields", "");
component.set("v.commonProductFields", "");
}
});
$A.enqueueAction(action);
}
I am unable to display the specific fields for some reason.
I would expect a null pointer exception on console log because
var errors
are empty, but I am new to JS, so I am guessing thats just how JS works?I had to
Enable Profile Access for Apex Class
for various profiles the controller class of this component, otherwise I was gettingYou do not have access to the Apex class named...
, which is strange because I never did it before and it was working fine until now. Why now this error is occuring?