function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
knght4yshuaknght4yshua 

Maximum call stack size exceeded??

Hey all, I'm getting the following error and I have no idea 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}"/>:&nbsp;&nbsp;&nbsp;<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:
({
    /*
     * 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);

Any help you can provide is greatly appreciated!

Thanks!

 
Raj VakatiRaj Vakati
Refer this link ..  share the code  for  DependentPicklistTestController class  


https://salesforce.stackexchange.com/questions/145406/setcallback-maximum-call-stack-size-exceeded
https://salesforce.stackexchange.com/questions/129573/lightning-locker-service-maximum-call-stack-size-exceeded-on-action-getcallback
https://success.salesforce.com/issues_view?id=a1p3A000000jkqqQAA
https://success.salesforce.com/issues_view?id=a1p3A000000jkqqQAA
knght4yshuaknght4yshua
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;
    }
}

 
knght4yshuaknght4yshua
Hey Raj,

Any updates for me here?

Thanks!!
Alain CabonAlain Cabon
Hi,

<aura:attribute name="selectedValue" type="String"/>
 value="{!v.selectedOption}"

Please fix this beginner's error first.