Search code examples
javascriptdynamics-crmdynamics-crm-online

How to edit the selection fields that are shown in the preferred method of contact field


I would like to remove the fax option from the preferred method of contact picker. Currently the options of Any Email Phone Fax and Mail are shown (image included below) and I would like to remove Fax from the list. I am currently using

var preferredContactMethodCode = Xrm.Page.getAttribute('preferredcontactmethodcode').getValue();

to access the values but I don't know how to edit the values. Any documentation that you can find on the subject would be greatly appreciated as well.

preferred method of contact screen-capture


Solution

  • Use RemoveOption to remove the option set option at run time.

    Xrm.Page.getControl('preferredcontactmethodcode').removeOption(4); //4-Fax
    

    To remove the option set altogether (which I would never suggest doing on an out of the box field), customize the option set (CRM customizations, field customizations) and remove/delete the option set option (You will lose data).