1
votes

As we know Dynamics CRM has a specific attribute value: Customer. This value combines the Client and Account entity, but I'm blind or MSDN doesn't have specification about retrieving this field in query. For example:

QueryByAttribute query = new QueryByAttribute(entName);
query.ColumnSet = new ColumnSet(new String[] { searchAttr });
query.Attributes.Add(searchAttr);
query.Values.Add(searchValue);

EntityCollection retrived = service.RetrieveMultiple(query);

This code accepts entity name and searches the attribute's name and value, but when I run it I don't know which type of entity I get from my DataSouce: Client or Account. So the question is: is it possible to retrieve Customer entity in one query?

1
Check .LogicalName of each recordAlex
Yes. I'm doing it now. But I just wondering: maybe there is a specific way to work with this type?Krivitskiy Grigoriy
I'm not aware of anyAlex

1 Answers

5
votes

No, you must first know which entity you are trying to retrieve.


Get the value held within the Customer field as an EntityReference:

var customer = entity.GetAttributeValue<EntityReference>("customerid");

Get the LogicalName of the EntityReference:

var customerEntity = customer.LogicalName;