Showing posts with label setOptionSetValueByText. Show all posts
Showing posts with label setOptionSetValueByText. Show all posts

Wednesday, June 8, 2016

How to set Optionset Valueby Text

function setOptionSetValueByText() {
    var optionText = Xrm.Page.getAttribute("statuscode").getText();
    var options = Xrm.Page.getAttribute("new_status").getOptions();
    for (i = 0; i < options.length; i++) {
        if (options[i].text == optionText) {
            Xrm.Page.getAttribute("new_status").setValue(options[i].value);
        }
    }
}