You need to sign in to do that
Don't have an account?
Naeem T-Pearson
how to resolve unable to find action error
i am receiveing this error
This page has an error. You might just need to refresh it. Unable to find action 'getBoatTypes' on the controller of c:BoatSearchForm Failing descriptor: {c:BoatSearchForm}
here are the relative components
boatSearchForm.cmp
<aura:component controller="BoatSearchFormApexController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<aura:attribute name="selectType_boat_attribute" type="String[]" default="All Types"/>
<aura:attribute name="newBtnShow" type="boolean"/>
<aura:registerEvent name="startBoatForm" type="c:startBoatForm"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="startBoatForm" event="c:startBoatForm" action="{!c.handleBoatForm}"/>
<lightning:layout horizontalAlign="center" VerticalAlign="end">
<lightning:layoutItem flexibility="auto" padding="around-small">
<lightning:select aura:id="selectTypeBoat" name="selectType" label="">
<option value="">All Types</option>
<aura:iteration items="{!v.selectType_Boat_attribute}" var="option">
<option value="!option" text="!option"/>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem flexibility="auto" padding="around-large">
<lightning:button label="search" variant="brand" onclick="{!c.boatSearch}"/>
</lightning:layoutItem>
<aura:if isTrue="{!v.newBtnShow}">
<lightning:layoutItem flexibility="auto" padding="around-large">
<lightning:button label="new" variant="neutral" onclick="{!c.newBtnClick}"/>
</lightning:layoutItem>
</aura:if>
</lightning:layout>
</aura:component>
boatSearchFormController.js
({
doInit : function(component, event, helper) {
alert('---->');
var action = component.get("c.getBoatTypes");
action = setCallback(this, function(response){
var state = response.getState;
$A.log(response);
if(state === "success"){
component.set("v.selectType_boat_attribute", response.getReturnValue());
}
});
$A.enqueueAction(action);
var isEnabled = component.get("e.force:createRecord");
//check if isEnabled is true
if (isEnabled) {
component.set("v.newBtnShow", true);
}
}
})
boatSearchFormApexController.apxc
public with sharing class BoatSearchFormApexController
{
public static list<BoatType__c> getBoatTypes()
{
return [Select Id, Name from BoatType__c];
}
}
boatSearch.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<lightning:card class="slds-m-bottom_x-small" title="Find a Boat">
<c:BoatSearchForm/>
</lightning:card>
<lightning:card class="slds-m-bottom_x-small" title="Matching Boats">
<c:BoatSearchResults/>
</lightning:card>
</aura:component>
FriendsWithBoats.app
<aura:application extends="force:slds">
<c:BoatSearch/>
</aura:application>
This page has an error. You might just need to refresh it. Unable to find action 'getBoatTypes' on the controller of c:BoatSearchForm Failing descriptor: {c:BoatSearchForm}
here are the relative components
boatSearchForm.cmp
<aura:component controller="BoatSearchFormApexController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<aura:attribute name="selectType_boat_attribute" type="String[]" default="All Types"/>
<aura:attribute name="newBtnShow" type="boolean"/>
<aura:registerEvent name="startBoatForm" type="c:startBoatForm"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="startBoatForm" event="c:startBoatForm" action="{!c.handleBoatForm}"/>
<lightning:layout horizontalAlign="center" VerticalAlign="end">
<lightning:layoutItem flexibility="auto" padding="around-small">
<lightning:select aura:id="selectTypeBoat" name="selectType" label="">
<option value="">All Types</option>
<aura:iteration items="{!v.selectType_Boat_attribute}" var="option">
<option value="!option" text="!option"/>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem flexibility="auto" padding="around-large">
<lightning:button label="search" variant="brand" onclick="{!c.boatSearch}"/>
</lightning:layoutItem>
<aura:if isTrue="{!v.newBtnShow}">
<lightning:layoutItem flexibility="auto" padding="around-large">
<lightning:button label="new" variant="neutral" onclick="{!c.newBtnClick}"/>
</lightning:layoutItem>
</aura:if>
</lightning:layout>
</aura:component>
boatSearchFormController.js
({
doInit : function(component, event, helper) {
alert('---->');
var action = component.get("c.getBoatTypes");
action = setCallback(this, function(response){
var state = response.getState;
$A.log(response);
if(state === "success"){
component.set("v.selectType_boat_attribute", response.getReturnValue());
}
});
$A.enqueueAction(action);
var isEnabled = component.get("e.force:createRecord");
//check if isEnabled is true
if (isEnabled) {
component.set("v.newBtnShow", true);
}
}
})
boatSearchFormApexController.apxc
public with sharing class BoatSearchFormApexController
{
public static list<BoatType__c> getBoatTypes()
{
return [Select Id, Name from BoatType__c];
}
}
boatSearch.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
<lightning:card class="slds-m-bottom_x-small" title="Find a Boat">
<c:BoatSearchForm/>
</lightning:card>
<lightning:card class="slds-m-bottom_x-small" title="Matching Boats">
<c:BoatSearchResults/>
</lightning:card>
</aura:component>
FriendsWithBoats.app
<aura:application extends="force:slds">
<c:BoatSearch/>
</aura:application>
Use this code