Filter Option Set depending on another option set values by using java script in D365 CRM

I have filter option set by using another option set values with java script.


function OptionSetValuesAddRemove(executionContext)
{
     
    formContext = executionContext.getFormContext();
    
    var independentOptionSet = formContext.getAttribute("new_independentoptionset").getValue()
 
    var dependentOptionSet = formContext.ui.controls.get("new_dependentoptionset");
    var optionSetValues = dependentOptionSet.getAttribute().getOptions();
 
    dependentOptionSet.clearOptions();
 
    optionSetValues.forEach(function (element)
    {
 
       if (independentOptionSet == "100000000") {
            if (element.value == 100000013)
                dependentOptionSet.addOption(element);
        }
       
        if (independentOptionSet == "100000002") {
            if (element.value == 100000013)
                dependentOptionSet.addOption(element);
        }
        if (independentOptionSet == "100000006") {
            if (element.value == 100000013)
                dependentOptionSet.addOption(element);
        }
     
        if (independentOptionSet == "100000000") {
            if (element.value == 100000013)
                dependentOptionSet.addOption(element);
        }
        
        
    }
    );
}

No comments:

Post a Comment