Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Fetch XML Query - Linking to Entity

Posted on by 1,608

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 

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Fetch XML Query - Linking to Entity

    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

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

Product updates

Dynamics 365 release plans