MS CRM 2011: Replacement of textbox with picklist with configurable values

While working with CRM 4.0, I used this trick to solve similar tasks. Today, I had to implement similar functionality and I decided to go the supported way – JavaScript + WebResources.

Create a html webresource with the following content (I called it xrm_picklist.htm):

Now embed your control into the form where you will use it:

Pay attention to the custom parameter passed to your webresource – getValuesFunction=XrmSolutions.getValues|sourceField=xrm_name|label=Dynamic Optionset

getValuesFunction – the name of the function that should be available in one of JS webresources of CRM form.

sourceField – schema name of the field to which the value selected in dropdown will be saved.

label – is the label that will be shown near the dropdown control.

Here is the code of JS Webresource that I used for a getValuesFunction:

In this case I used a static list, but you can use any kind of string array.

Here is the design with the form and webresource on it:

Form and JS webresource that contains method to fill picklist:

Save and publish the form. Here is demonstration of how this functionality works:

Leave a Reply

Your email address will not be published. Required fields are marked *