Hey Goutam, i add the attribute names and option-set values to the function and set to to trigger in type attribute onChange event, but it doesn't seems to be working, i was wondering maybe i should use Client API object module instead off Xrm.Objectmodule as you have use here ?
and when using XRM. Object do i have to pass ExecutionContext as the perimeter? below is the refracted code that i use
function OptionSetAddRemove() {
var type = Xrm.Page.getAttribute("crmcust_type").getValue(); // Replace Type field name
var optionSet = Xrm.Page.ui.controls.get("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);
});
}