Thursday, May 27, 2010

Creating a Lookup with Javascript in Crm 4

This is one on those things that i always forget how to do it so i am posting it. 

From the SDK:

//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object. = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
lookupItem.typename = 'account'; = 'A Bike Store';
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
crmForm.all.parentaccountid.DataValue = lookupData;