- How do I capture the value of an associated Lookup field?
- Posted by Andy Slocombe on February 26th, 2008
I am trying to capture the value of an associated Lookup field so that I may
then parse it out to something usable in the Contact entity. I have tried
several methods for "crmForm.all.attribute.method" including "returnvalue",
DataValue" and "toString" without much success. They usually yield
"[object]" or "[object, object]".
Anyone have success capturing like this, or have a better way of achieving
the same end?
Thanks! Andy.
- Posted by George Doubinski on February 26th, 2008
Straight from SDK:
var lookupItem = new Array;
// Get the lookup for the primarycontactid attribute 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)
{
// Display the text value of the lookup.
alert(lookupItem[0].name);
// Display the entity type name.
alert(lookupItem[0].typename);
// Display the GUID of the lookup.
alert(lookupItem[0].id);
// Display the entity type code of the lookup. A value of 1 equals
account, and a value of 2 equals contact.
alert(lookupItem[0].type);
}
Is that what you're after?
--
George Doubinski
CRM Certified Professional - Developer
Blog: http://crm.georged.id.au/
"Andy Slocombe" <andys@outreach.umass.edu> wrote in message
news:9F865C76-B98E-41D6-8663-28412C0C893B@microsoft.com...
- Posted by Andy Slocombe on February 28th, 2008
Thank you George! It's spitting out real data, so I assume I can manipulate
that same data to my heart's content 
Thanks again, Andy.
"George Doubinski" <georged.delete@alexanders.remove.net.au> wrote in
message news:eXy#uoMeIHA.4744@TK2MSFTNGP06.phx.gbl...