You need to sign in to do that
Don't have an account?

Why my controller is not returning anything?
I try to get a specified field from the account that im in, but for some reason i can't . Here is my code
Aura comp:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
<aura:attribute name="account" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
</aura:component>
Js controller
({
init : function(component, event, helper) {
var action = component.get("c.getAcc");
action.setParams({
"accid": component.get("v.recordId")
});
action.setCallback(this, function(a) {
component.set("v.account", a.getReturnValue());
});
$A.enqueueAction(action);
var test = component.get("v.account");
alert(test.Bridger_check__c);
}
})
Apex controller
@AuraEnabled
public static List<Account> getAcc(String accid) {
return [SELECT id,Bridger_check__c
FROM Account
WHERE id =: accid
LIMIT:1];
}
Aura comp:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="AccountController">
<aura:attribute name="account" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
</aura:component>
Js controller
({
init : function(component, event, helper) {
var action = component.get("c.getAcc");
action.setParams({
"accid": component.get("v.recordId")
});
action.setCallback(this, function(a) {
component.set("v.account", a.getReturnValue());
});
$A.enqueueAction(action);
var test = component.get("v.account");
alert(test.Bridger_check__c);
}
})
Apex controller
@AuraEnabled
public static List<Account> getAcc(String accid) {
return [SELECT id,Bridger_check__c
FROM Account
WHERE id =: accid
LIMIT:1];
}
Can you try below code and let us know the output.
Component:
Controller:
Apex Class:
All Answers
Can you try below code and let us know the output.
Component:
Controller:
Apex Class:
cos it not recognized toastParams
}else if(state === "ERROR"){
var errors = response.getError();
et toastParams = {
title: "Error",
message: "Unknown error", // Default error message
type: "error"
};
// Pass the error message if any
if (errors && Array.isArray(errors) && errors.length > 0) {
toastParams.message = errors[0].message;
}
// Fire error toast
let toastEvent = $A.get("e.force:showToast");
toastEvent.setParams(toastParams);
toastEvent.fire();
}
if i remove it and run it in order to test it
Error while creating component for lightning component quick action [Unable to find action 'getAcc' on the controller of c:LCC]
For the second error, please check if AccountController has the method getAcc or not. The method should be annotated with @AuraEnabled
Error while creating component for lightning component quick action [Unable to find action 'getAcc' on the controller of c:LCC]
was beacuse of not having the auraEnabled