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

Unable to resolve "Unable to find action 'getBoatTypes' on the controller of c:BoatSearchForm Failing descriptor: {c:BoatSearchForm}"
Hi,
I've been learning Lightning Components on Trailhead. I'm currently doing the project for the Lightning Superbadge and have been running into the following error when I try to reload the page for the standalone app:
I've googled around and have found a lot of examples of this error where people hadn't added the @AuraEnabled annotation to their server-side controller, so the client-side controller couldn't find the method.
But, I have added that annotation and am still getting the message. It's driving me up the wall. I haven't had this issue on any other controllers I've created, and I even have another method in the same server-side controller that is being referenced by the client with no issues.
Here's my client-side controller:
and my server-side controller:
I've been learning Lightning Components on Trailhead. I'm currently doing the project for the Lightning Superbadge and have been running into the following error when I try to reload the page for the standalone app:
Unable to find action 'getBoatTypes' on the controller of c:BoatSearchForm Failing descriptor: {c:BoatSearchForm}
I've googled around and have found a lot of examples of this error where people hadn't added the @AuraEnabled annotation to their server-side controller, so the client-side controller couldn't find the method.
But, I have added that annotation and am still getting the message. It's driving me up the wall. I haven't had this issue on any other controllers I've created, and I even have another method in the same server-side controller that is being referenced by the client with no issues.
Here's my client-side controller:
({ handleInit: function(component, event, helper) { // Check environment can create record var canCreateRecord = $A.get('e.force:createRecord'); component.set('v.canCreateRecord', !!canCreateRecord); // Get boat types to populate boat type dropdown var getBoatTypesAction = component.get('c.getBoatTypes'); getBoatTypesAction.setCallback(this, function(response) { var state = response.getState(); if(state === 'SUCCESS') { component.set('v.boatTypes', response.getReturnValue()); } else { console.log('Failed with state:', state); } }); $A.enqueueAction(getBoatTypesAction); }, createNewBoat : function(component, boatType) { var boatType = component.get('v.boatType'); var createAction = component.get('c.createBoat'); createAction.setParams({ "type": boatType }); action.setCallback(this, function(response) { var state = response.getState(); if(state === "SUCCESS") { console.log('SUCCESS'); } else { console.log(state); } }); $A.enqueueAction(createAction); } })
and my server-side controller:
public class BoatSearchApexController { @AuraEnabled public static void createBoat(String type) { Boat__c boat = new Boat__c(); if(type != null) { BoatType__c boatType = new BoatType__c(Name=type); insert boatType; boat.BoatType__c = boatType.Id; } insert boat; } @AuraEnabled public static List<BoatType__c> getBoatTypes() { return [Select Id, Name From BoatType__c]; } }
All Answers
Try this :
handleInit: function(component, event, helper) {
// Check environment can create record
var canCreateRecord = $A.get('e.force:createRecord');
component.set('v.canCreateRecord', !!canCreateRecord);
// Get boat types to populate boat type dropdown
var action = component.get('c.getBoatTypes');
action.setCallback(this, function(response) {
var state = response.getState();
if(state === 'SUCCESS') {
component.set('v.boatTypes', response.getReturnValue());
} else {
console.log('Failed with state:', state);
}
});
$A.enqueueAction(action);
},
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
Thanks, but unfortunately just changing the variable name of the action is not the answer. We can use any variable name for the action.
Regards
Joe
Joe Lemmer was correct. i also didnt add the controller to my component. thanks
The attributes include the property: access="PRIVATE"
I experienced the 'Unable to find action...' error. I had already included @AuraEnabled on my Apex controller method, and specified the controller on the component.
The issue was resolved when I removed ' access="PRIVATE" ' from the attributes.
Thanks Mike Arthur for your resolution.I was looking for this from last 2 days and also included @AuraEnabled on my Apex controller method, and specified the controller name on the component . But it didn't work.
Removing the property:access = "PRIVATE" really worked.