web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Incorrect link in FetchXML linked entity

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    ashlega Profile Picture
    34,477 on at

    It should work if you add link-type="outer" to each of those other linked entities.

  • Community Member Profile Picture
    on at

    Hi Alex,

    Thank you very much for your help, this worked!

    I assume this means that the link-entity is standard linked as an inner join?

  • ashlega Profile Picture
    34,477 on at

    It seems so. Though I don't have a reference to the documentation for that:)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans