Reputation: 277
For example, if I have a contact lookup field, and each contact record has many attributes, such as id, name, company, etc. How do I get the value of, say, the company attribute?
Thanks in advance.
Update:
I can now get the value id ({55FCBC5D-xxxx-xxxx-xxxx-005056A63DAF}) using Retrieve method provided by crm service, but i also need the text name of the value. How can I do that?
Upvotes: 0
Views: 4728
Reputation: 277
Problem solved by using two queries (Retrieve method provided by crmService).
Upvotes: 0
Reputation: 5352
A contact lookup field is of type EntityReference
. As such, it only contains the bare essentials needed to uniquely identify the record: its Id
(in this case, "ContactId"), LogicalName
(the name of the entity to which the reference belongs - in this case, "contact"), and, if you're lucky, Name
(in this case, likely FullName
).
So to get any additional information about the contact, you're going to have to ask the Contact
entity for that information via a query using the EntityReference
.Id
. There's lots of examples of this @StackOverflow and around the web - see CRM 2011: Getting entity with Javascript for a popular way here.
There is also a CodePlex project called "CRM 2011 Lookup Preview" that seems to cleverly preview this sort of information on forms, but this may/may not be what you're looking for.
Upvotes: 1