Tuesday 30 October 2018

Add/Insert New Value into OPTIONSET - Microsoft Dynamics CRM.

add a new optionset to an Option (javascript)

Description:

In this example, we explain that how to get or set Option Set item dynamically in Dynamic CRM using JavaScript. Alternatively, how to Add/Insert new value into Option Set in Dynamic CRM using JavaScript. Here in this example we explain that how to add New Items in Option Set control in Dynamic CRM using JavaScript. Or dynamically add or remove Option to an Option Set using JavaScript in Dynamic CRM.or add new Option Set to an Option in Dynamic CRM using JavaScript.in below example ="example-enableFiltering" is the id of the Select.
Code:

 function popOptSet() {
            debugger;
                                   
            var options = window.parent.Xrm.Page.getControl("new_countriesoptionset").getOptions();
            var newoptionset = document.getElementById("example-enableFiltering");

            // *** Clear current items
            for (var i = 0; i < options.length; i++) {

                //newoptionset.addOption(" {value :" + options[i].value + ", text : " + options[i].text + "}");
                var option = document.createElement("OPTION");
                //Set Customer Name in Text part.
                option.innerHTML = options[i].text;
                //Set CustomerId in Value part.
                option.value = options[i].value;
                //Add the Option element to DropDownList.
                newoptionset.options.add(option);
            }
        }

<select id="example-enableFiltering" ></select>


0 comments:

Post a Comment