我正在尝试构建与SQL query等价物的FetchXML,我对FetchXML的使用非常陌生:
SELECT o.opportunityid,c1.accountid
FROM dbo.opportunity o
LEFT JOIN dbo.account c1 on o.customerid = c1.accountid and o.customeridtype = 1 转到
<fetch mapping="logical" version="1.0">
<entity name="opportunity">
<attribute name="opportunityid" />
<link-entity name="account" from="accountid" to="customerid" alias="A1" link-type="outer" >
<filter type="and" >
<condition attribute="customeridtype" operator="eq" value="1" />
</filter>
<attribute name="accountid" />
</link-entity>但这是抛出错误,说属性"customeridtype“不存在于实体"account”中。该属性来自SQL查询中的opportunity实体。我该如何解决这个问题呢?
发布于 2020-02-19 21:13:42
我刚刚在我的一个Dynamics实例中触发了这个,并给出了正确的结果
<fetch>
<entity name="opportunity" >
<attribute name="opportunityid" />
<attribute name="customeridtype" />
<filter type="and" >
<condition attribute="customeridtype" operator="eq" value="1" />
</filter>
<link-entity name="account" from="accountid" to="customerid" link-type="outer" alias="Account" >
<attribute name="accountid" alias="AccountId" />
</link-entity>
</entity>
</fetch>发布于 2020-02-19 21:17:58
从内部link-entity xml节点到外部entity节点取出filter。
你可以试试XrmToolBox fetchxml builder或者Kingswaysoft sql2fetchxml在线工具。
<fetch mapping="logical" version="1.0">
<entity name="opportunity">
<attribute name="opportunityid" />
<filter type="and" >
<condition attribute="customeridtype" operator="eq" value="1" />
</filter>
<link-entity name="account" from="accountid" to="customerid" alias="A1" link-type="outer" >
<attribute name="accountid" />
</link-entity> https://stackoverflow.com/questions/60300296
复制相似问题