Thursday, November 29, 2018

Disable/Hide an option set value


Get Option Set selected Text and Value
var osTextValue = UpdateOptionSetCatA1.getAttribute().getText();
var osValue = UpdateOptionSetCatA1.getAttribute().getValue();
Disable/Hide an option set value
function UpdateOptionSet() {  

var UpdateOptionSetSchema = Xrm.Page.ui.controls.get("new_optionsetschema");

   var osValue= UpdateOptionSetSchema.getAttribute().getValue();

if (osValue== null){

Xrm.Page.getControl("new_optionsetschema").removeOption('optionsetIntegerValue');

}

if (osValue!= 'optionsetIntegerValue'){

Xrm.Page.getControl("new_optionsetschema").removeOption('optionsetIntegerValue');

}

}

Reset field value to the default optionset option with Javascript

I think you might be able to get that value by using the getInitialValue method
var defaultValue = Xrm.Page.getAttribute(osName).getInitialValue();
Xrm.Page.getAttribute(osName).setValue(defaultValue);
Hope this helps.
Thanks,
Anuj Govil