Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to write FetchXML that filters for all entities that are not linked to a related entity

(0) ShareShare
ReportReport
Posted on by 59

Hello all,

I have created a custom entity that links to the contact entity. There can be an arbitrary number of records of the custom entity referencing one contact (N:1). I want to create a view that only shows those contacts where no records of the custom entity pointing to it exists. I have found a way to create a view that filters only the records that have at least one associated record:

<fetch>
<entity name="contact">
<link-entity name="new_customentity" from="new_contact" to="contactid" />
</entity>
</fetch>

Is there a way to invert this view or how do I solve this?

Thanks

  • Suggested answer
    furkank Profile Picture
    furkank 535 on at
    RE: How to write FetchXML that filters for all entities that are not linked to a related entity

    Hi, You can use FetchXML Builder by Jonas Rapp. You can build more complex queries and Copy their XML's.

    see this link:  www.xrmtoolbox.com/.../

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,081 Moderator on at
    RE: How to write FetchXML that filters for all entities that are not linked to a related entity

    Hi Nicolas Krauter,

    Use Fetch Builder in XRM Tool Box and create queries using the user interface and get whatever format you like. It has all the options you required. Further details: FetchXML Builder for XrmToolBox - empower yourself to achieve more.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: How to write FetchXML that filters for all entities that are not linked to a related entity

    Hi Nicolas,

    You can use a left outer join in FetchXML to perform a query that filters on the join table.

    You can perform a left outer join in FetchXML by using the entityname column as a condition operator. The entityname column is valid in conditions, filters, and nested filters. 

    You can refer to the following link for more examples:

    https://learn.microsoft.com/en-us/power-apps/developer/data-platform/use-fetchxml-left-outer-join-query-records-not-in 

    pastedimage1666664276282v1.png

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: How to write FetchXML that filters for all entities that are not linked to a related entity

    Hello,

    Check this post - www.arbelatech.com/.../how-to-use-not-in-filter-in-dynamics-365-for-customer-engagement-v9.html

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans