1

Can someone please tell me the oData equivalent query for the below fetchXml query?

<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">
<entity name="customeraddress">
<attribute name="name"/>
<link-entity name="contact" alias="ab" to="parentid" from="contactid">
<filter type="and">
<condition attribute="statecode" value="0" operator="eq"/>
</filter>
</link-entity>
</entity>
</fetch>

I looked up a lot and tried what was mentioned here: Filter on Expanded entities in OData but doesn't work.

Community
  • 1
  • 1
Payal
  • 73
  • 2
  • 13

1 Answers1

2

Unfortunately it is not possible to build OData query that will include expand on related entity and filter on it but if you work with Dynamics CRM 2016 new WebApi can use clear FetchXml for data querying.

Recheck following articles:

jasonscript
  • 6,039
  • 3
  • 28
  • 43
Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13
  • thank you very much for this information!! I will have to use multiple query calls for now. – Payal Jan 06 '16 at 18:23
  • FYI, it _is_ possible to expand and filter with OData. The URI syntax is `$expand=contact($filter=statecode eq 0)`. See [System Query Option $expand](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398162). Whether your service endpoint supports this feature is a different matter. – lencharest Jan 06 '16 at 19:53
  • 2
    FYI @lencharest Question is Microsoft Dynamics CRM specific where OData endpoint doesn't support filtering by expanded relationships. – Andrew Butenko Jan 06 '16 at 20:42