Add AND statement to WHERE clause in FETCH XML?

2019-09-14 06:27发布

问题:

We have this below fetchXML, I have a quick question wondering how I add this and statement to the WHERE clause: and ip.pcssu_quantityavailable >= sod.quantity - sod.quantityshipped to the fetchXML?

<fetch mapping="logical" version="1.0">
  <entity name="SalesOrder">
    <attribute name="ordernumber" />
    <attribute name="statuscode" />
    <attribute name="statuscodename" />
    <attribute name="pcssu_stockavailable" />
    <filter>
      <condition attribute="statuscode" operator="eq" value="141560004" />
    </filter>
    <link-entity name="SalesOrderDetail" from="salesorderid" to="salesorderid" alias="sod" link-type="inner">
      <attribute name="productidname" />
      <attribute name="quantity" />
      <attribute name="quantityshipped" />
      <link-entity name="pcssu_inventoryproduct" from="pcssu_product" to="productid" alias="ip" link-type="inner">
        <attribute name="pcssu_quantityavailable" />
      </link-entity>
    </link-entity>
    <link-entity name="account" from="accountnumber" to="pcssu_servicecentrecode" alias="a" link-type="inner" />
  </entity>
</fetch>

回答1:

I'm afraid that FetchXml doesn't support such syntax. I'm really sorry for that. Also to make your fetch work use your entity names lowercased like salesorder and salesorderdetail (not SalesOrder and SalesOrderDetail).