Action failed: ui:inputSelect$controller$valueChange [Maximum call stack size exceeded]
COMPONENT CODE:
<aura:component access="global" controller="DependentPicklistTestController">
<aura:attribute name="object" type="String"/>
<aura:attribute name="controllingField" type="String"/>
<aura:attribute name="dependentField" type="String"/>
<aura:attribute name="selectedValue" type="String"/>
<aura:attribute name="fieldName" type="String"/>
<aura:attribute name="selectedDependentOption" type="String"/>
<aura:attribute name="isDependentDisable" type="Boolean" default="false"/>
<aura:handler name="init" value="{!this}" action="{!c.loadOptions}" />
<ui:outputText value="{!v.fieldName}"/>: <ui:inputSelect aura:id="picklistOptions"
disabled="{!v.isDependentDisable}"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.selectedOption}"
required="true"
onError="{!c.handleError}"
onClearErrors="{!c.handleClearError}"/>
</aura:component>
CONTROLLER CODE:
({
loadOptions : function(component, event, helper) {
helper.getOptionsHp(component, component.get("v.object"), component.get("v.controllingField"), component.get("v.dependentField"), component.get("v.selectedValue"));
}
})
HELPER CODE:
If I comment out this line the error goes away, but then again so does the information I need!:({
/*
* Function to get all picklist values for a controlling/dependent pair
*/
getOptionsHp: function(component, obj, controllingField, dependentField, selectedValue) {
var optionValues = [];
var action;
if(dependentField == "NULL"){
action = component.get("c.getTopLevelOptionsApx");
action.setParams({
'obj' : obj,
'field' : controllingField});
}
else{
action = component.get("c.getOptionsApx");
action.setParams({
'obj' : obj,
'controllingField' : controllingField,
'dependentField' : dependentField});
}
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS" && !$A.util.isEmpty(response.getReturnValue()) && !$A.util.isUndefined(response.getReturnValue())) {
var returnedValues = response.getReturnValue();
component.set("v.optionsMap",returnedValues);
optionValues.push({
class: "optionClass",
label: "--- None ---",
value: "--- None ---",
selected: true
});
if($A.util.isUndefined(selectedValue) || $A.util.isEmpty(selectedValue) || selectedValue == "NULL"){
for(var i = 0; i < returnedValues.length; i++){
optionValues.push({
class: "optionsClass",
label: returnedValues[i],
value: returnedValues[i]
})
}
}
else{
for(var i = 0; i < Object.values(returnedValues[selectedValue]).length; i++){
optionValues.push({
class: "optionsClass",
label: Object.values(returnedValues[selectedValue])[i],
value: Object.values(returnedValues[selectedValue])[i]
})
}
}
component.find("picklistOptions").set("v.options",optionValues);
}
else if(state === "ERROR"){
('A problem occurred: ' + JSON.stringify(response.error));
}
});
$A.enqueueAction(action);
}
})
Any help you can provide is greatly appreciated!Thanks!component.find("picklistOptions").set("v.options",optionValues);
Thanks Raj. I had already checked out the first link before posting here and don't believe it applies, but maybe I'm missing something. Here is the controller code you requested: public class DependentPicklistTestController {
/*
* Retrieve all controlling and dependent picklist options
*/
@AuraEnabled
public static Map<String,List<String>> getOptionsApx(String obj, String controllingField, String dependentField){
Map<String,List<String>> optionsMap = new Map<String,List<String>>();
DependentPicklistController dpc = new DependentPicklistController();
optionsMap = dpc.getOptions(obj, controllingField, dependentField);
return optionsMap;
}
/*
* Retrieve all picklist options for top-level fields (those which have no dependencies)
*/
@AuraEnabled
public static List<String> getTopLevelOptionsApx(String obj, String field){
List<String> options = new List<String>();
Schema.SObjectType objectType = Schema.getGlobalDescribe().get(obj);
Map<String, Schema.SObjectField> fieldMap = objectType.getDescribe().fields.getMap();
Schema.DescribeFieldResult fieldResults = fieldMap.get(field).getDescribe();
List<Schema.PicklistEntry> ples = fieldResults.getPicklistValues();
for(Schema.PicklistEntry ple : ples){
options.add(ple.getValue());
}
return options;
}
}