Get the name of a lookup that is not resolved


I often have to check the name value of a lookup field.
In normal cases one would use the code crmForm.all.new_lookupfield.DataValue[0].name to retrieve this value.

In case of an ambiguous or failed lookup, this datavalue will be null.

Ambiguous lookup
LookupAmbiguous

What I found out using the IE Developer toolbar was that this kind of lookups used a <span> element to display this “unresolved” state of a lookup.
Both resolved and unresolved lookups have this Span. The only difference will be the classname. So if you like, you can also filter on the className.

LookupAmbiguousHTML

So, to access the Text of this Lookup I could use crmForm.all.metris_blueprintid_d.getElementsByTagName(“span”)[0].outerText

Advertisements
Tagged with: ,
Posted in CRM 4
One comment on “Get the name of a lookup that is not resolved
  1. Matias says:

    Hi. Do you know how to do this in CRM 2011? Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: