Dynamics 365 Fetchxml实现跨表or或者and的关系,而且eq需要用like实现(如果字段名在两个表都存在)
在系统的高级查找,是配置不出跨表or或者and的:

可以这样写Fetchxml来实现:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"> <entity name="contact"> <attribute name="fullname" /> <attribute name="telephone1" /> <attribute name="contactid" /> <order attribute="fullname" descending="false" /> <filter type="and"> <filter type="or"> <condition attribute="emailaddress1" operator="eq" value="572752" /> <condition entityname="ai" attribute="name" operator="eq" value="xxx" /> </filter> </filter> <link-entity name="account" from="accountid" to="parentcustomerid" link-type="inner" alias="ai"> <!-- 已移除嵌套过滤器 --> </link-entity> </entity> </fetch>
上面的Fetchxml,有可能会出现name="xxx"不生效的现象,通过监听sql,发现name="xxx"识别到了contact,后来将eq改成like就可以解决问题。
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"> <entity name="contact"> <attribute name="fullname" /> <attribute name="telephone1" /> <attribute name="contactid" /> <order attribute="fullname" descending="false" /> <filter type="and"> <filter type="or"> <condition attribute="emailaddress1" operator="eq" value="572752" /> <condition entityname="ai" attribute="name" operator="like" value="xxx" /> </filter> </filter> <link-entity name="account" from="accountid" to="parentcustomerid" link-type="inner" alias="ai"> <!-- 已移除嵌套过滤器 --> </link-entity> </entity> </fetch>
记得收藏并关注,掌握更多相关知识!!!

浙公网安备 33010602011771号