Let's Get Started: A tutorial of how to use the below JavaScript code to filter/hide specific option set values based on a selection from a different option set.
function OnChangeCategoryOptions() {
try {
var optionSetCategoryVal = Xrm.Page.getAttribute("option set A schema name").getSelectedOption().value;
var optionSet = Xrm.Page.ui.controls.get("option set B schema name");
var optionSetValues = optionSet.getAttribute().getOptions();
optionSet.clearOptions();
} catch (e) {
console.log(e); // Write error to console
return
}
optionSetValues.forEach(function (element) {
if (optionSetCategoryVal == null) {
if (element.value == "")
optionSet.addOption(element);
}
else if (optionSetCategoryVal == "option set A first value") {
if (element.value == "option set B value" || element.value == "option set B value" || element.value == "option set B value")
optionSet.addOption(element);
}
else if (optionSetCategoryVal == "option set A second value") {
if (element.value == "option set B value" || element.value == "option set B value" || element.value == "option set B value")
optionSet.addOption(element);
}
});
}
Ещё видео!