Sorry. i worked it out. i also added a handler for NULL.
function onMultiSelectChange(executionContext) {
const formContext = executionContext.getFormContext();
const moField = formContext.getAttribute("mso_field");
//Returns Array of Selected OptionSet Values, example [1001,1002,1005 ]
const selectedOptions = moField.getSelectedOption();
// Now you can implement your logic here, for example:
if(selectedOptions != null){
if(selectedOptions.filter(i => i.value === 100000000).length > 0) {
// Hide mobile phone field
formContext.getControl("field1").setVisible(true);
} else {
// Show mobile phone field
formContext.getControl("field1").setVisible(false);
}
if(selectedOptions.filter(i => i.value === 100000001).length > 0) {
// Hide mobile phone field
formContext.getControl("field2").setVisible(true);
} else {
// Show mobile phone field
formContext.getControl("field2").setVisible(false);
}
}
if(selectedOptions == null){
formContext.getControl("field1").setVisible(false);
formContext.getControl("field2").setVisible(false);
}
}