You need to sign in to do that
Don't have an account?
knght4yshua
Maximum call stack size exceeded on InputSelect
Never received a final response to my last question... really need to get this one working. Can someone help?
I am getting this error and I don't know why:
COMPONENT CODE:
JS CONTROLLER CODE:
JS HELPER CODE:
If I comment out this line the error goes away, but then again so does the information I need!:
APEX CONTROLLER CODE:
Any help you can provide is greatly appreciated!
Thanks!
I am getting this error and I don't know why:
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>
JS 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")); } })
JS HELPER CODE:
({ /* * 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); } })
If I comment out this line the error goes away, but then again so does the information I need!:
component.find("picklistOptions").set("v.options",optionValues);
APEX CONTROLLER CODE:
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; } }
Any help you can provide is greatly appreciated!
Thanks!
There is the same basic error here:
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005amRQAQ
<aura:attribute name="selectedValue" type="String"/>
value="{!v.selectedOption}"
Please fix this beginner's error first (that cannot work otherwise).
Is it solved now?
@Raj V: news from Adam Drissel 7?
He doesn't come back here but the solution is obvious for his problem.
All Answers
The code of DependentPicklistController is missing.
DEPENDENT PICKLIST CONTROLLER:
The code of PicklistEntryWrapper is just missing now.
Any updates? Do you need any more of the code?
Helper .js
I just found that selectedOption is not defined as an attribute or use selectedValue instead of selectedOption
and that is the cause of your error.
Nothing serious but the effect is blocking.
1) Missing in the component: <aura:attribute name="selectedOption" type="String"/>
or value="{!v.selectedValue}"
2) Not an error below but: console.log seems missing.
else if(state === "ERROR"){
console.log('A problem occurred: ' + JSON.stringify(response.error));
}
3) Some semicolons are missing sometime (not a error either and allowed with javascript that will add them automatically internally but it is sometime dangerous)
optionValues.push({
class: "optionsClass",
label: Object.values(returnedValues[selectedValue])[i],
value: Object.values(returnedValues[selectedValue])[i]
}) ;
Finally, there is a minor error (selectedValue instead of selectedOption or vice-versa)
There is the same basic error here:
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005amRQAQ
<aura:attribute name="selectedValue" type="String"/>
value="{!v.selectedOption}"
Please fix this beginner's error first (that cannot work otherwise).
Is it solved now?
@Raj V: news from Adam Drissel 7?
He doesn't come back here but the solution is obvious for his problem.