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 365 | Integration, Dataverse...
Suggested Answer

Fetch XML Query - Linking to Entity

(0) ShareShare
ReportReport
Posted on by 987

I am relatively new to FetchXML and am trying to structure a query linking two entities.  These entities are respectively invoice and invoiceitem, with a one to many relationship.  Both share a common guid field:  ts_invoiceid, and I've confirmed that the same guid exists in both entities.  I can query the two entities independently, but if I try to join them together, nothing appears for the to entity.  The first entity in the query always displays, but the second linked entity appears as null.

In troubleshooting,

1)  I've reversed the order of the query, and it is always the to values that appear null.

2)  I've tried this selecting both all attributes and specific attributes and the results are the same

3)  I also tried applying a filter to narrow the scope of the query, but again have the same results.  

4)  I've also tried explicitly setting the link as an Inner Join

A sample of the query is below.  Is there anything syntax or structure wise that would be preventing the join?  Or anything else that may be a consideration?  Please advise.  Look forward to a response.

<fetch mapping='logical'>
      <entity name='ts_invoiceitem'>
       <all-attributes />
              <link-entity name="ts_invoice" to="ts_invoiceid" from="ts_invoiceid">
              <all-attributes />
               </link-entity>
</entity>
</fetch>

JG 

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi JG,

    How do you run your request? I recommend using the FetchXml Builder tool available on XrmToolBox, it will allow you to easily generate and execute your queries.

    pastedimage1622824030261v2.png

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans