MSCRM 2011 Multi Lookup

MSCRM 2011 Multi Lookup:

In MS CRM by default it provides the look up to select a single record in it. If we want to select more than one record with in the same llo up we need to do some Javs Script coding on that look up .

Here we can trigger the script events in Onload and Onsave.

Steps to Follow to setup a Multi Value Look Up:

1) Form shuold have the One Lookup .

2) Shoold place on Multi Line Text Field on the form.


Create On Javascript Web Resource and Paste the Following Code, then add it to the Web Resource Library.

Add the web resource to your Form, and call the functions in Onload and OnSave events is as follows.


Onload Event Code:

//Call this Function on Form Load  Event

function load() {

document.getElementById(” Lookup Schema Name”).setAttribute(“lookupstyle”, “multi”);
document.getElementById(” Lookup Schema Name”).setAttribute(“_lookupstyle”, “multi”);

if (Xrm.Page.ui.getFormType() != 1) {
var data = new Array();
// I created a one multiline text box to save the lookup values.
// set the multiline textbox visible equal to false.
var store = Xrm.Page.getAttribute(” Multi line text Schema Name”).getValue();

data = store.split(“;”);

var typename = “Target Record Type”;

var arr = new Array();
var i = 0;
var j = 0;

for (i = 0; i < ((data.length – 1) / 2); i++) {
arr[i] = new Object();
arr[i].name = data[j];
arr[i].id = data[j + 1];
arr[i].typename = typename;
j = j + 1;
if(i!=0 && j!=0)
crmForm.all[” Lookup Schema Name”].DataValue = arr;

//Call this Function on Save Event

function save() {

var value = crmForm.all[” Lookup Schema Name”].DataValue;
var s;
var temp = “”;

for (s = 0; s < value.length; s++) {
var temp2 = “”;
temp2 = value[s].name + “;” + value[s].id + “;”;
temp = temp + “” + temp2;
Xrm.Page.getAttribute(” Multi line text Schema Name”).setValue(temp);
Xrm.Page.getAttribute(” Lookup Schema Name”).setValue(null);
document.getElementById(” Lookup Schema Name”).setAttribute(“lookupstyle”, “single”);



Leave a Reply

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

You are commenting using your 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