Friday, 19 January 2018

Remove item from picklist with javascript



Xrm.Page.getControl("new_salesstagecode").removeOption(1);

Check a value exists in a OptionSet MS CRM


Use Below method to check whether a picklist contains a value:

Parameters:

  var options = Xrm.Page.getAttribute('statuscode').getOptions();

options: list of options
valueToCheck: Int


function StatusContainsValue(options, valueToCheck) {
    var found = false;
    for (var i = 0; i < options.length; i++) {
        if (vendors[i].value == valueToCheck) {
            found = true;
            break;
        }
    }
}