Home > CRM, Javista, Microsoft, Microsoft Dynamics, Microsoft Dynamics CRM Online > Dynamic Pick List from a custom entity in Dynamics CRM Online

Dynamic Pick List from a custom entity in Dynamics CRM Online

The purpose of a dynamic pick list is to allow you to make modifications to the list with as little impact as possible. Static list are effective for data that doesn’t change often. For list values that need updating, a dynamic pick list is the trick. In addition, you could use the same technique to pull data from external systems and make available in the list.

The method I’ll describe is pretty well known ( see www.stunnware.com as well). I thought it’d be good to revisit and put it up on the blog.

The method uses a custom entity to hold the values for the pick list and jscript to load the values into the picklist when the form loads.
The jscript will query the data using the CRM web services. You could just as easily call into other web services that return data from external systems or have the custom entity that holds the data get update externally as well.


I’ve created a sample that allows me to pull from a list of promotional events and show on the lead form

Here are the steps.

1. Create a custom entity to hold the values – Promotions, well use the name attribute to load in the list

2. Create a pick list on the lead form to hold the values , promotionlist

3. Add the jscript to the OnLoad form event.



Lead form with the dynamic pick list for promotions.



This is the custom entity Promotions, that hold the values to be put in the list.  You can update the values here and they will automatically show up
for other users in the list. By managing security on the Promotions entity, you can control who updates the list.


Make sure you enabled the Jscript in the lead form onload event after you put it in.

Below is the jscript you’ll need to add.

Notes –
new_name is the attribute name that we want to pull from the promotion entity.
new_promotionlist is the pick list we will add values to.
You can remove the comments // on the alert messages to help with debugging.   // alert(msg);

var xml = “” +
“<?xml version=\”1.0\” encoding=\”utf-8\”?>” +
“<soap:Envelope xmlns:soap=\”http://schemas.xmlsoap.org/soap/envelope/\” xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” xmlns:xsd=\”http://www.w3.org/2001/XMLSchema\“>” +
GenerateAuthenticationHeader() +
” <soap:Body>” +
” <RetrieveMultiple xmlns=\”http://schemas.microsoft.com/crm/2007/WebServices\“>” +
” <query xmlns:q1=\”http://schemas.microsoft.com/crm/2006/Query\” xsi:type=\”q1:QueryExpression\”>” +
” <q1:EntityName>new_promotion</q1:EntityName>” +
” <q1:ColumnSet xsi:type=\”q1:ColumnSet\”>” +
” <q1:Attributes>” +
” <q1:Attribute>new_name</q1:Attribute>” +
” </q1:Attributes>” +
” </q1:ColumnSet>” +
” <q1:Distinct>false</q1:Distinct>” +
” </query>” +
” </RetrieveMultiple>” +
” </soap:Body>” +
“</soap:Envelope>” +

var xmlHttpRequest = new ActiveXObject(“Msxml2.XMLHTTP”);

xmlHttpRequest.Open(“POST”, “/mscrmservices/2007/CrmService.asmx”, false);
xmlHttpRequest.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
xmlHttpRequest.setRequestHeader(“Content-Length”, xml.length);

// Capture the result.
var resultXml = xmlHttpRequest.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes(‘//error’).length;
if (errorCount != 0)
var msg = resultXml.selectSingleNode(‘//description’).nodeTypedValue;
// Parse and display the results.
var results = resultXml.getElementsByTagName(‘BusinessEntity’);
var msg = “”;
var pick = crmForm.all.new_promotionlist;  // List
if (results.length == 0)
  msg = “No records found”;
// alert(msg);
  var entityNodes = resultXml.selectNodes(“//RetrieveMultipleResult/BusinessEntities/BusinessEntity”);

  // Loop through the collection of returned entities.
  for (var i = 0; i < entityNodes.length; i++)
      var entityNode = entityNodes[i];
      var nameNode = entityNode.selectSingleNode(“q1:new_name“);
      var name = (nameNode == null) ? null : nameNode.text;




  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: