I'm trying to set a Option set value based up on another option set value, my requirements as below,
based on Case Type option set the subtype option set should filter off
If
Type =CRM
Subtype Options :-
Data Request, Development ,Physician services , Provider Measure, Technical Support
If
Type = Administrative
Subtype Options :-
Assembly, Leader training, Printing ,Resource center, Supply, Support , Webinar
If
Type =IT
Subtype Options :-
Equipment request, IT support, Security , Users
here is the JavaScript im using ATM
function OptionSetAddRemove(executionContext) {
var formContext = executionContext.getFormContext();
var type = formContext.getAttribute("crmcust_type").getValue(); // Replace Type field name
var optionSet = formContext.getControl("new_subtype"); // Replace Sub Type field name
var optionSetValues = optionSet.getAttribute().getOptions(); // retrieve All options of Option set field
if (type == "155,330,001") // the value of type = CRM
{
optionSet.clearOptions();
optionSetValues.forEach(function (element) {
if (element.value == "100,000,000" || element.value == "100,000,001" || element.value == "100,000,002" || element.value == "100,000,003" || element.value == "100,000,004") // replace the value of options of Data Request, Development ,Physician services , Provider Measure, Technical Support
optionSet.addOption(element);
if (element.value == "100,000,005" || element.value == "100,000,006" || element.value == "100,000,007" || element.value == "100,000,008" || element.value == "100,000,009" || element.value == "100,000,010" || element.value == "100,000,011" || element.value == "100,000,012" || element.value == "100,000,013" || element.value == "100,000,014" || element.value == "100,000,015") // replace the value of options of Assembly, leader training, printing ,resource center, supply, support , Webinar
optionSet.removeOption(element);
});
}
}
i have set above code to Type Attribute onChange event , the code is not doing anything at the moment, there is no error, but code is not working, any help would greatly appreciate