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.

Process:

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();

if(store!=null)
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 = 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”);
}

 Cheers,

MS Dynamics CRM 2011 Entity Images

MS CRM 2011 Entity Images

PreEntityImages :(Gets the properties of the primary entity before the core platform operation has begins)

PreEntityImages used to capture the data when the form loads. That is the data which is present by default when the form loads.  The syntax for using the PreEntityImages in CRM 2011 is changed as compared to CRM 4.0.

Note:The PreEntityImages cannot be registered for “create” operation.

Syntax Used in CRM 2011 :
=======================

Suppose you registered the Plugin and added a Image with name “PreImage

public EntityImageCollection PreEntityImages { get;}
PostEntityImages : (Gets the properties of the primary entity after the core platform operation has been completed. )

The PostEntityImages contains the attributes value which are finally changed. We can capture the changed data before the database operation takes place. And can do any kind of validation based on the changed data.

Note: PostEntityImages can only be registered  for Update message and cannot be registered on Create message.

Syntax Used in CRM 2011 :

Suppose you registered the Plugin and added a Image with name “PostImage

Syntax:
=========
public EntityImageCollection PostEntityImages { get; }

Cheers,