Hello,
I am trying to build a view with an OR clause over different entities, something CRM does not support out of the box (if I'm not mistaken). Therefore, I am trying to build the query manually in FetchXML (using XRM Toolbox). I am looking for Opportunities, and one of the attributes I want to filter on, is the Owner of the Opportunity.
The following query results in 2 entries, which is correct as I am owner of 2 Opportunities:
<entity name="opportunity" >
<link-entity name="systemuser" from="systemuserid" to="ownerid" visible="true" alias="ow" />
<attribute [list of attributes...] />
<filter type="and" >
<condition entityname="ow" attribute="systemuserid" operator="eq-userid" />
</filter>
</entity>
However, when I add the other link-entity that I need, the query runs correctly, but results in 0 entries:
<entity name="opportunity" >
<link-entity name="systemuser" from="systemuserid" to="ownerid" visible="true" alias="ow" />
<link-entity name="team" from="regardingobjectid" to="opportunityid" alias="aa" link-type="outer" >
<link-entity name="teammembership" from="teamid" to="teamid" visible="true" intersect="true" >
<link-entity name="systemuser" from="systemuserid" to="systemuserid" visible="true" alias="ab" />
</link-entity>
</link-entity>
<attribute [list of attributes...] />
<filter type="and" >
<condition entityname="ow" attribute="systemuserid" operator="eq-userid" />
</filter>
</entity>
So it seems that in the latter query, the condition is applied to another entity than the one the alias is referring...
PS: I tried the same query without the first link-entity (to system user), and use the native ownerid field of an Opportunity. This results in the same problem. I added the link-entity in order to be able to add an alias to the filter condition.
Anyone has any idea how I could solve this?
All help would be very much appreciated, thank you in advance!
Benjamin
*This post is locked for comments