Dynamics CRM 2011 · Javascript

CRM 2011: Add new Picklist Option using Javascript

Here are a couple of ways to add new picklist option using Javascript

var picklistControl = Xrm.Page.getControl("new_picklistfield");

var opt1 = new Option();
opt1.text = "one";
opt1.value = 1;

var opt2 = new Option();
opt2.text = "two";
opt2.value = 2;

//picklistControl.addOption(<option>, <index>);
picklistControl.addOption(opt1, 0);
var picklist = document.getElementById("new_picklistfield");

//picklist.AddOption(<text>, <value>);
picklist.AddOption("one", 1);

Cheers – Sy

12 thoughts on “CRM 2011: Add new Picklist Option using Javascript

  1. Thank you Sy. It works,but how can I get the text value of the picklist on the OnChange Event,it’s always blank.

  2. i was able to add options to the picklist, on save contact i was not able to get value of
    selected option

    Xrm.Page.getAttribute(“new_amprecipientlisttemp”).getSelectedOption() its always coming as null

    1. Hi Philip, my guess is that you’re saving directly after changing the value. At that time the field value hasn’t ‘changed’ yet. Try clicking somewhere in the form and then try the save again. Hope that helps.

      Cheers – Sy

  3. Not working on CRM 2015. I am able to view options in the option list but after selecting value it is not displaying on option set.

    1. Hi Chandan,

      The article is written for CRM 2011, so may not work for other versions. Feel free to post the solution when you find out.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s