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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans