Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXML to retrieve related records under parentaccount record

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi experts,

I am trying to construct fetchXML to retrieve count of cases that were created in the last 90 days for all account under and including the parent account.

For example:

Parent account A contains 1 case 

Child account B contains 1 case 

Child account C contains 1 case 

So the count in this case would be 3. 

I have the following fetchXML but when I test it on http://msxrmtools.com/fetchxml it is not returning correct values.

I'm sure there is something wrong with my xml. Please help as to what I can change to make it work. 

<fetch mapping='logical' distinct='false' aggregate='true'><entity name='incident'><attribute name='title' alias='recordcount' aggregate='count' /><filter type='and'><condition attribute='createdon' operator='last-x-days' value='90' /></filter><link-entity name='account' from='parentaccountid' to='customerid' link-type='inner' alias='ab'><filter type='and'><condition attribute='accountid' operator='eq' value='{EC2EAB2C-BF51-E811-A955-000D3A33EB4E}' /></filter></link-entity></entity></fetch>


Thanks.

Jon

*This post is locked for comments

  • Suggested answer
    sardar ahmed Profile Picture
    sardar ahmed 520 on at
    RE: FetchXML to retrieve related records under parentaccount record

    Hi Jon,

    I think you need to write another fetch to get the child account for the selected account and then pass them to your fetchxml to get the cases.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: FetchXML to retrieve related records under parentaccount record

    For anyone who may find this thread,

    We simply have to replace the operator with operator='eq-or-under' and from='accountid'

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans