Export (0) Print
Expand All

Field Type: Lookup or PartyList

CRM 1.2
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.


Example

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.
   alert(lookupItem[0].name);

   // The GUID of the lookup.
   alert(lookupItem[0].id);

   // The entity type name.
   alert(lookupItem[0].typename);

   // The entity type code of the lookup: 1=account, 2= contact.
   // This attribute is deprecated. Use typename instead.
   alert(lookupItem[0].type);
}

Example

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.
   lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
   lookupItem.typename = 'account';
   lookupItem.name = '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.


Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft