Adding a multi-select field to CRM forms

Best Regards from Innovar Tecnologías

Display Listbox fields

– Data types for fields in CRM do not include data type list box for marking multiple options. But it is possible to deploy this functionality using scripts on the form – In this example we will generate a multiple choice list for a field named ‘Products of interest’ on the Account entity



– The deployment includes the following components

– An option field in September to boost the values ​​listed – A web resource to display js listbox on the form – A multiline field to store the items marked in comma separated values

– The code in the onLoad event of the form to display the list is as follows:

displayList function (optionset) {

AllProducts var = optionSet.getOptions ();

tdProducts var = document.getElementById (‘new_productosinteres_d’);

tdProducts.innerHTML = “”;

listProducts = “<div style=’overflow-y:auto; height:200px;’>”;

listProducts + = “<table>”;

for (var i = 1; i <allProducts.length, i + +) {

listProducts + = “<tr> <td width=’20px’>”;

listProducts + = ‘<input width = ’20px’

+ Onclick = ‘addProduct (this)’ id = ‘product_ “+ i

+ “‘Type =’ checkbox ‘value ='” + AllProducts [i]. Text + “‘>”;

listProducts + = “</ td> <td>”;

listProducts + = “+ i + for=’product_” <label “‘>”

+ AllProducts [i]. Text + “</ label>”;

listProducts + = “</ td> </ tr>”;

}

listProducts + = “</ table> </ div>”;

tdProducts.innerHTML + = listProducts;

}

– And the control code to complete the multiline field below:

addProduct function (item) {

Xrm.Page.getAttribute selectedProducts var = (“new_productosinteres”). getValue ();

if (item.checked) {

Xrm.Page.getAttribute (“new_productosinteres”). SetValue (selectedProducts

+ “,” + Item.value);

}

else {

selectedProducts = selectedProducts.replace (“,” + item.value, “”);

Xrm.Page.getAttribute (“new_productosinteres”). SetValue (selectedProducts);

}

}

The result is the following


Advertisements

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: