Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Fetch XML Unions?

Posted on by 92

Does anyone know how to write a query that can replicate a SQL UNION statement in Fetch XML?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Fetch XML Unions?

    Hello,

    I'm with David - it's not possible to create something similar to SQ Union in FetchXml but... there is a workaround you can use and it is described here - butenko.pro/.../

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Fetch XML Unions?

    This isn't possible. If you are submitting the FetchXml query via code (e.g. via RetrieveMultiple), it is relatively simple to submit multiple queries and combine the result sets in code. However, if using FetchXML in a report then there is no useful workaround.

    In a few specific cases you could contrive a workaround by rewriting the query to join to a common entity - for example if you wanted all leads and opportunities created by a user, you could use the following query, then have a calculated column to combine either the lead subject or opportunity name. Note the use of outer joins.

      
        
        
         
        
        
         
        
      
    

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans