RemoveOption for Option set
function OptionSetAddRemove() { var optionSet = Xrm.Page.ui.controls.get("new_myoptionset"); var optionSetValues = optionSet.getAttribute().getOptions(); // retrieve All options of Option set field optionSet.clearOptions(); optionSetValues.forEach(function (element) { if (element.value == "831260009") // Add Options which you want to show based on value optionSet.addOption(element); if (element.value == "831260008") // Remove options which you want to hide based on value optionSet.removeOption(element); }); }
function OptionSetAddRemove(executionContext) {
formContext = executionContext.getFormContext();
var independentOptionSetValues = formContext.getAttribute("new_independentoptionsetvalues").getValue()
var dependentOptionSetValues = formContext.ui.controls.get("new_dependentoptionsetvalues");
var optionSetValues = dependentOptionSetValues.getAttribute().getOptions();
dependentOptionSetValues.clearOptions();
optionSetValues.forEach(function (element) {
if (independentOptionSetValues == "100000007") {
if (element.value == 100000007 || element.value == 100000000 || element.value == 100000002)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000004") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000008") {
if (element.value == 100000003 || element.value == 100000004 || element.value == 100000005 || element.value == 100000011 || element.value == 100000006 || element.value == 100000001)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000002") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000006") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000005") {
if (element.value == 100000008 || element.value == 100000012 || element.value == 100000010 || element.value == 100000009 || element.value == 100000001)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000000") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000003") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
if (independentOptionSetValues == "100000001") {
if (element.value == 100000013)
dependentOptionSetValues.addOption(element);
}
}
);
}
Comments
Post a Comment