Field Type: Lookup or PartyList

banner art

A Lookup object is defined with the following attributes:

Attribute Type Description
id String The GUID of the item. Required for set.
type Integer Deprecated. The object type code.
typename String The entity name of the item. Required for set.
name String The name of the item to be displayed. Required for set.
data   Any other data. Optional for set.

The following properties are available:

Lookup or PartyList properties Type Description
{Field}.DataValue An array of lookup objects Get/set property.

For single lookups this must be an array with the length of one. DataValue is Null when no value is selected. Set DataValue to Null to make the lookup field blank.


The following code example shows how to read values from a field of type Lookup.

var lookupItem = new Array;

// This will get the lookup for the attribute primarycontactid on the Account form.
lookupItem = crmForm.all.primarycontactid.DataValue;

// If there is data in the field, show it in a series of alerts.
if (lookupItem[0] != null)
   // The text value of the lookup.

   // The GUID of the lookup.

   // The entity type name.

   // The entity type code of the lookup: 1=account, 2= contact.
   // This attribute is deprecated. Use typename instead.


The following code example shows how to set values in a field of type Lookup. This example shows how to set the parent account lookup field on the account form.

//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;

© 2007 Microsoft Corporation. All rights reserved.