oData query raises an error when you use CRM Complex Type field as a condition

This article helps you resolve the problem that occurs when you use a complex type field as a condition.

Applies to:   Microsoft Dynamics CRM 2011
Original KB number:   2500892

Symptoms

oData query raises an error when you use a complex type field as a condition.

The following query will raise an error:

XRMServices/2011/OrganizationData.svc/AccountSet?$select=Name&$filter=PrimaryContactId/LogicalName%20ne%20null

Cause

This is a change from the Dynamics CRM 2011 beta release. In Dynamics CRM 2011 you cannot use complex type field as a condition. Please remove field name. For EntityReference, you are able to use Id field.

Resolution

Replace the query with either of the following to resolve the issue.

  • XRMServices/2011/OrganizationData.svc/AccountSet?$select=Name&$filter=PrimaryContactId%20ne%20null
  • XRMServices/2011/OrganizationData.svc/AccountSet?$select=Name&$filter=PrimaryContactId/Id%20ne%20null