? ? ? 看一段FetchXML, 這段查詢在XRMtoolbox中的fech test工具里執行完全ok
<fetch version="1.0" mapping="logical" distinct="true" no-lock="false">
<entity name="new_projectchange">
<link-entity name="systemuser" alias="aa" link-type="inner" from="systemuserid" to="ownerid">
<link-entity name="new_projectmajorcode" alias="ab" link-type="inner" from="new_projectmajorcodeid" to="new_projectmajorcodeid">
<attribute name="new_purchaseapproval"/>
<link-entity name="systemuser" alias="sys" link-type="inner" from="systemuserid" to="new_purchaseapproval">
<attribute name="internalemailaddress"/>
</link-entity>
</link-entity>
</link-entity>
<filter type="and">
<condition attribute="new_projectchangeid" operator="eq" value="d16d9ba9-fa89-f011-b4cc-002248582342"/>
</filter>
</entity>
</fetch>
? ? ? 但是在list rows的步驟中卻執行失敗了,提示Key property 'new_projectchangeid' of type 'Microsoft.Dynamics.CRM.new_projectchange' is null. Key properties cannot have null values.
? ? ?最開始以為是我的condition中的value取值錯誤,一直是空,但最后哪怕我寫死值,還是報一樣的錯
? ? ?最后我調整了下語句, 在頂部enitty下面加了一個attribute屬性,完美解決。
<fetch version="1.0" mapping="logical" distinct="true" no-lock="false">
<entity name="new_projectchange">
<attribute name="new_projectchangeid"/>
<link-entity name="systemuser" alias="aa" link-type="inner" from="systemuserid" to="ownerid">
<link-entity name="new_projectmajorcode" alias="ab" link-type="inner" from="new_projectmajorcodeid" to="new_projectmajorcodeid">
<attribute name="new_purchaseapproval"/>
<link-entity name="systemuser" alias="sys" link-type="inner" from="systemuserid" to="new_purchaseapproval">
<attribute name="internalemailaddress"/>
</link-entity>
</link-entity>
</link-entity>
<filter type="and">
<condition attribute="new_projectchangeid" operator="eq" value="d16d9ba9-fa89-f011-b4cc-002248582342"/>
</filter>
</entity>
</fetch>