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
Yes Ajith, Apparently that value is a Int , i did remove the string value as well as the , separating the numbers, that did the trick, code is working now, thanks!
Hi Kalana,
Can you please remove "," from the values in your conditions and see if it works e.g. change your first if condition to : if (type == "155330001")
Thanks,
Ajit
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,818 Super User 2024 Season 2
Martin Dráb 229,147 Most Valuable Professional
nmaenpaa 101,156