In this blog, we will show how to hide the options from the option set in the dynamics 365 crm.

for this blog i am using Country and Status Reason fields. if the country is equals to the India and some of the options in the status reason will be hidden using the JavaScript.

Change the schema names and option set values in the below code based on your requirement

function HideOptions(executionContext) {
      var formContext = executionContext.getFormContext();
      var Country = formContext.getAttribute(“crmonce_country”).getValue();
      var Status = formContext.getControl(“statuscode”);

      if (Country == 741350000) {
          Status.removeOption(741350000);
          Status.removeOption(741350001);
          Status.removeOption(741350003);
          Status.removeOption(741350004);
       }
   
};
Next test the code
Before

when country equals india the options are hidden in status reason

For any Help or Queries Contact us on info@crmonce.com or +918096556344.