How to clear options without leaving an empty entry

Using the clearOptions method on PickLists, can leave an empty entry because Drop Down lists in HTML must have at least one entry.

To work around use the following code that removes all options other than the current value to avoid the empty entry.

var attribute = Xrm.Page.getAttribute(“attributename”);
// NOTE: We can't use clearOptions since this adds an empty option 
// attribute.controls.forEach(function (control) { control.clearOptions(); })

for (var j = 0; j < attribute.getOptions().length; j++) {
    if (attribute.getValue() != attribute.getOptions()[j].value) {
        attribute.controls.forEach(function (control) {


If this doesn't work for you, the empty entry can be manually removed using:

attribute.controls.forEach(function (control) { 

Comments are closed