Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Setting value for option set

$
0
0

I am using Custom option set in contact form and i need to set n number of values to that field using java script i have json array set  i am not able to pull all the value in json and set it to that custom option field any one can please guide me with the proper java script code.

I have pasted my JavaScript code below

function Countrylist() {

var control = Xrm.Page.getAttribute("new_countrylist");
if (control.getAttributeType() == 'optionset')
 {

var arr=[{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"}];

 for (var i = 0; i < arr.length; i++){
                    

 Xrm.Page.getAttribute("new_countrylist").setValue(arr[i].name);
}
}
}


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>