Код:
var customer = new Array();
customer = null;
// This gets the lookup for the attribute customerid on the Opportunity form.
customer = crmForm.all.customerid.DataValue;
// If there is data in the field, show it in a series of alerts.
if (customer[0] != null)
{
// The name of the customer.
alert(customer[0].name);
// The GUID of the customer.
alert(customer [0].id);
// The entity type name of the customer.
alert(customer[0].typename);
}
Целиком взято из sdk. Открывайте его хоть иногда