You need to sign in to do that
Don't have an account?
VijayNi
Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues Component: c:PropertyDialog . Caused by: Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues
Hi Team,
I am doing a trailhead module on Aura Component to Override a Standard Action i am getting the below error . can someone help me why i am getting the below eroor .
A Component Error has occured! Error: Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues Component: c:PropertyDialog . Caused by: Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues.
a.G.get()@https://static.lightning.force.com/ap24/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:375:248
Object.value [as get]()@https://static.lightning.force.com/ap24/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:37:131667
doInit()@https://brave-badger-a5q453-dev-ed.lightning.force.com/lightning/r/Property__c/a065g000000pyldAAA/components/c/PickListValues.js:11:32
Property Dialog component :
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="PickListController" >
<aura:attribute name="picklistValues" type="Object" />
<force:recordData aura:id="forceRecord"
recordId="{!v.recordId}"
targetFields="{!v.propertyRecord}"
fields="Id,Name,Beds__c,Baths__c,Price__c,Status__c"
mode="EDIT" />
<aura:attribute name="propertyRecord" type="Property__c"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<c:PickListValues sObjectName="Property__c" fieldName="Status__c" picklistValues="{!v.picklistValues}" />
<lightning:input aura:id="propName" name="propName" label="Proprty Name" required="true"/>
<lightning:input aura:id="propBeds" name="propBeds" label="Beds" />
<lightning:input aura:id="propBaths" name="propBaths" label="price" />
<lightning:select aura:id="propStatus" name="propStatus" label="Status">
<aura:iteration items="{!v.picklistValues}" var="item">
<option value="{!item}">{!item}</option>
</aura:iteration>
</lightning:select>
<lightning:button variant="neutral" label="Cancel" />
<lightning:button variant="brand" label="Submit" />
</aura:component>
PickListvalues component:
<aura:component controller="PickListController" access="global" >
<aura:attribute name="sObjectName" type="String" />
<aura:attribute name="fieldName" type="String" />
<aura:attribute name="picklistValues" type="Object" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
PickList Controller:
global class PickListController{
@AuraEnabled
public static List<String> getPicklistValues(String ObjectApi_name,String Field_name){
List<String> lstPickvals=new List<String>();
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(ObjectApi_name);//From the Object Api name retrieving the SObject
Sobject Object_name = targetType.newSObject();
Schema.sObjectType sobject_type = Object_name.getSObjectType(); //grab the sobject that was passed
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap(); //get a map of fields for the passed sobject
List<Schema.PicklistEntry> pick_list_values = field_map.get(Field_name).getDescribe().getPickListValues(); //grab the list of picklist values for the passed field on the sobject
for (Schema.PicklistEntry a : pick_list_values) { //for all values in the picklist list
lstPickvals.add(a.getValue());//add the value to our final list
}
return lstPickvals;
}}
PickListValuesController:
({
doInit : function(component) {
var action = component.get("c.getPickListValuesIntoList");
action.setParams({
objectType: component.get("v.sObjectName"),
selectedField: component.get("v.fieldName")
});
action.setCallback(this, function(response) {
var list = response.getReturnValue();
component.set("v.picklistValues", list);
})
$A.enqueueAction(action);
}
})
I am doing a trailhead module on Aura Component to Override a Standard Action i am getting the below error . can someone help me why i am getting the below eroor .
A Component Error has occured! Error: Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues Component: c:PropertyDialog . Caused by: Unable to find action 'getPickListValuesIntoList' on the controller of c:PickListValues.
a.G.get()@https://static.lightning.force.com/ap24/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:375:248
Object.value [as get]()@https://static.lightning.force.com/ap24/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:37:131667
doInit()@https://brave-badger-a5q453-dev-ed.lightning.force.com/lightning/r/Property__c/a065g000000pyldAAA/components/c/PickListValues.js:11:32
Property Dialog component :
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="PickListController" >
<aura:attribute name="picklistValues" type="Object" />
<force:recordData aura:id="forceRecord"
recordId="{!v.recordId}"
targetFields="{!v.propertyRecord}"
fields="Id,Name,Beds__c,Baths__c,Price__c,Status__c"
mode="EDIT" />
<aura:attribute name="propertyRecord" type="Property__c"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<c:PickListValues sObjectName="Property__c" fieldName="Status__c" picklistValues="{!v.picklistValues}" />
<lightning:input aura:id="propName" name="propName" label="Proprty Name" required="true"/>
<lightning:input aura:id="propBeds" name="propBeds" label="Beds" />
<lightning:input aura:id="propBaths" name="propBaths" label="price" />
<lightning:select aura:id="propStatus" name="propStatus" label="Status">
<aura:iteration items="{!v.picklistValues}" var="item">
<option value="{!item}">{!item}</option>
</aura:iteration>
</lightning:select>
<lightning:button variant="neutral" label="Cancel" />
<lightning:button variant="brand" label="Submit" />
</aura:component>
PickListvalues component:
<aura:component controller="PickListController" access="global" >
<aura:attribute name="sObjectName" type="String" />
<aura:attribute name="fieldName" type="String" />
<aura:attribute name="picklistValues" type="Object" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
PickList Controller:
global class PickListController{
@AuraEnabled
public static List<String> getPicklistValues(String ObjectApi_name,String Field_name){
List<String> lstPickvals=new List<String>();
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(ObjectApi_name);//From the Object Api name retrieving the SObject
Sobject Object_name = targetType.newSObject();
Schema.sObjectType sobject_type = Object_name.getSObjectType(); //grab the sobject that was passed
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap(); //get a map of fields for the passed sobject
List<Schema.PicklistEntry> pick_list_values = field_map.get(Field_name).getDescribe().getPickListValues(); //grab the list of picklist values for the passed field on the sobject
for (Schema.PicklistEntry a : pick_list_values) { //for all values in the picklist list
lstPickvals.add(a.getValue());//add the value to our final list
}
return lstPickvals;
}}
PickListValuesController:
({
doInit : function(component) {
var action = component.get("c.getPickListValuesIntoList");
action.setParams({
objectType: component.get("v.sObjectName"),
selectedField: component.get("v.fieldName")
});
action.setCallback(this, function(response) {
var list = response.getReturnValue();
component.set("v.picklistValues", list);
})
$A.enqueueAction(action);
}
})
you are having the issue in below line in aura js. Referring the apex method name wrongly here.
var action = component.get("c.getPickListValuesIntoList"); --> var action = component.get("c.getPicklistValues");
({
doInit : function(component) {
var action = component.get("c.getPicklistValues");
action.setParams({
objectType: component.get("v.sObjectName"),
selectedField: component.get("v.fieldName")
});
action.setCallback(this, function(response) {
var list = response.getReturnValue();
component.set("v.picklistValues", list);
})
$A.enqueueAction(action);
}
})
Thanks,
Maharajan.C
Greetings!
Hope you find the below thread helpful to fix the issue.
https://developer.salesforce.com/forums/?id=9060G0000005M9f
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
I have checked your code and I have caught the mistake you have made. In PickListValuesController you are calling the method
var action = component.get("c.getPickListValuesIntoList");
In the PickList Controller, there is no method having the name getPickListValuesIntoList. That's why you are getting an error. so you need to call the right method from PickListValuesController i.e.
({
doInit : function(component) {
var action = component.get("c.getPicklistValues");
action.setParams({
objectType: component.get("v.sObjectName"),
selectedField: component.get("v.fieldName")
});
action.setCallback(this, function(response) {
var list = response.getReturnValue();
component.set("v.picklistValues", list);
})
$A.enqueueAction(action);
}
})
Hope this explanation will resolve your query. Mark it as the best answer if you find it helpful.
Thanks
Akshay