Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Incorrect link in FetchXML linked entity

Posted on by Microsoft Employee

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

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Incorrect link in FetchXML linked entity

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Incorrect link in FetchXML linked entity

    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?

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Incorrect link in FetchXML linked entity

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans