RetrieveMultiple Gotchas

This article is only relevant if you use the assemblies which are provided in the crm sdk

The crm webservice provides multiple ways for querying data. One of them uses the QueryExpression for selecting the data.

A QueryExpression can be used for retrieving data of any crm entity. However, if you use it to query the entities activitypointer or queueitem your crm webservice proxy will throw an InvalidOperationException with the message There is an error in XML document

So what are you doing wrong? Nothing.

This problem is (poorly) described in the sdkreadme.htm in the crm sdk.

Possible failure using the CrmService.RetrieveMultiple method found in SdkTypeProxy.dll (32227)

Calling this method may result in an InvalidOperationException.

Workaround: Use the CrmService.Execute method with the RetrieveMultiple message instead.

The described workaround leads to the same error. The only way to request data from these entities is to use DynamicEntities.
This requires a small change at your existing query: you only have to tell the CRM to return the results as DynamicEntities

RetrieveMultipleRequest request = new RetrieveMultipleRequest 
{ 
  Query = query, 
  ReturnDynamicEntities = true 
};

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.