FetchXMLBuilder icon indicating copy to clipboard operation
FetchXMLBuilder copied to clipboard

Not able to convert below fetchxml to Odata4.0 (Limitations)

Open kmtendulkar opened this issue 3 years ago • 5 comments

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
  <entity name="account">
    <attribute name="name" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="or">
      <condition attribute="customertypecode" operator="eq" value="3" />
      <condition attribute="type" entityname="ah" operator="eq" value="990000002" />
    </filter>
    <link-entity name="opportunity" from="parentaccountid" to="accountid" link-type="outer" alias="ah">
      <filter type="and" />
    </link-entity>
  </entity>
</fetch>

kmtendulkar avatar Nov 25 '22 15:11 kmtendulkar

The attribute type does not exist on the opportunity entity, in my environment. Maybe that has a typo? Are you sure you have that attribute?

I tried with another attribute that works, but it is still impossible to convert to OData 4.0 - might be a limit in the Dataverse? I guess @MarkMpn knows more in this area?

rappen avatar Nov 26 '22 15:11 rappen

Yes, I'm not aware of an OData equivalent to the filter condition using the entityname attribute. If you know what this query should look like so it produces the same results from OData as for FetchXML please let me know!

MarkMpn avatar Nov 27 '22 10:11 MarkMpn

The attribute type does not exist on the opportunity entity, in my environment. Maybe that has a typo? Are you sure you have that attribute?

I tried with another attribute that works, but it is still impossible to convert to OData 4.0 - might be a limit in the Dataverse? I guess @MarkMpn knows more in this area?

Its a custom field and I dont want to disclose. Yeah. you can try with different field but it does not work for Odata 4.0

kmtendulkar avatar Nov 27 '22 21:11 kmtendulkar

Yes, I'm not aware of an OData equivalent to the filter condition using the entityname attribute. If you know what this query should look like so it produces the same results from OData as for FetchXML please let me know!

if I dont use entity name and adds the filter in the link-entity then it generates below odata. but Instead of AND comdition in filter, I want OR condition. Not sure if there is any alternative.

https://crmdev.api.crm4.dynamics.com/api/data/v9.2.22103.194/accounts?$select=name,telephone1,new_sapid,customertypecode,address1_composite,_new_intermediary_value,_ownerid_value,accountclassificationcode,new_excustomer,accountid&$expand=opportunity_parent_account($select=new_type;$filter=(new_type eq 990000002))&$filter=(customertypecode eq 3) and (opportunity_parent_account/any(o1:(o1/new_type eq 990000002)))&$orderby=name asc

kmtendulkar avatar Nov 27 '22 21:11 kmtendulkar

Sorry @kmtendulkar, this has been quiet for a while... I'm unsure if we need some fixing in my tool, or is it simple query issues (==Microsoft should fix it)?

rappen avatar Feb 06 '23 14:02 rappen