working on a tutorial at home with Microsoft Dynamics 365 CRM, to hide a Option Set Value from a dropdown, however this dropdown also is used on a Business Process Flow, I dont want to delete the Option Set Value, just hide it i.e. removeopotion/hide.
Im trying to use JavaScript to hide/remove this, however Im very new to JS and dont really understand it, my code is below:
function hideOptions(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1 || formContext.ui.getFormType() == 2 ) {
var pickList = formContext.Page.getControl("statuscode");
pickList.removeOption("Test1");
pickList.removeOption("Test2");
pickList.removeOption("Test3");
pickList.removeOption("Test4");
}
}
Please advise.
working on a tutorial at home with Microsoft Dynamics 365 CRM, to hide a Option Set Value from a dropdown, however this dropdown also is used on a Business Process Flow, I dont want to delete the Option Set Value, just hide it i.e. removeopotion/hide.
Im trying to use JavaScript to hide/remove this, however Im very new to JS and dont really understand it, my code is below:
function hideOptions(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1 || formContext.ui.getFormType() == 2 ) {
var pickList = formContext.Page.getControl("statuscode");
pickList.removeOption("Test1");
pickList.removeOption("Test2");
pickList.removeOption("Test3");
pickList.removeOption("Test4");
}
}
Please advise.
Share Improve this question edited Aug 25, 2021 at 13:59 Arpit 3251 silver badge9 bronze badges asked Aug 25, 2021 at 13:48 The GThe G 831 gold badge1 silver badge12 bronze badges2 Answers
Reset to default 3You should provide the numeric value in the removeOption
method.
As it's said in microsoft docs
formContext.getControl(arg).removeOption(value);
value - Number - The value of the option you want to remove.
I fixed this now thank you guys, was missing the correct schema name name "header_statuscode"
function hideOptions(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1 || formContext.ui.getFormType() == 2 ) {
var pickList = formContext.getControl("header_statuscode");
pickList.removeOption(1);
pickList.removeOption(2);
}
}