![](/img/trans.png)
[英]Microsoft Dynamics 365 can I use FetchXML to retrieve an entity by guid?
[英]Dynamics 365 FetchXML - Use IN operator for string
因為我需要創建一個查詢,我需要添加一個過濾條件,其中有效的實體類型可以是 e1、e2、e3 中的任何一個。
為此,我目前已在 FetchXML 下方編寫:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
<entity name="changelog" >
<filter type="and" >
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="event" operator="eq" value="Delete" />
<filter type="or" >
<condition attribute="entitytype" operator="eq" value="email" />
<condition attribute="entitytype" operator="eq" value="fax" />
<condition attribute="entitytype" operator="eq" value="letter" />
<condition attribute="entitytype" operator="eq" value="phonecall" />
</filter>
</filter>
<order attribute="statuscode" />
<order attribute="event" />
<order attribute="createdon" />
</entity>
</fetch>
上面的查詢正在傳遞預期的記錄。
但是,我相信也可以有另一種方法 - 通過對實體類型條件使用 IN 運算符。
為了測試該查詢,我使用了 XRMTool 的FetchXML Tester ,它會引發錯誤。 查詢如下:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
<entity name="changelog" >
<filter type="and" >
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="event" operator="eq" value="Delete" />
<condition attribute="entitytype" operator="in" >
<value>
phonecall
</value>
<value>
email
</value>
<value>
fax
</value>
<value>
letter
</value>
</condition>
</filter>
<order attribute="statuscode" />
<order attribute="event" />
<order attribute="createdon" />
</entity>
</fetch>
上面的查詢結果沒有返回任何記錄。
注意:我已使用 FetchXML 測試人員的格式按鈕對其進行了格式化。
有什么幫助嗎?
原因是FetchXML Tester提供的默認格式選項。
它格式化 FetchXML 的方式是它不返回任何值的原因。
它應該被格式化如下:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
<entity name="changelog" >
<filter type="and" >
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="event" operator="eq" value="Delete" />
<condition attribute="entitytype" operator="in" >
<value>phonecall</value>
<value>email</value>
<value>fax</value>
<value>letter</value>
</condition>
</filter>
<order attribute="statuscode" />
<order attribute="event" />
<order attribute="createdon" />
</entity>
</fetch>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.