Joseph Michael Pesch
VP Programming

MS CRM Lookup Field DataValue Property JavaScript

by 3. November 2010 17:41

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 != 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);

}

 

 

Tags:

[None]

Comments are closed