web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

FetchXML linked entity filter based on parent entity

(0) ShareShare
ReportReport
Posted on by

How can i create a fetchxml query where the linked entity is filtered based on the parent entity. see the bold, red condition below. How can I achieve that??

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' >
<entity name='entity1' >
<attribute name='entity1_primaryid' />
<link-entity name='entity2' from='entity2_relationshipfield' to='entity1_primaryid' 
link-type='outer' > <filter type='and' > <condition entityname='entity2' attribute='createddate' operator='eq'
value="enity1_datecreated"+5days /> </filter> </link-entity> </entity> </fetch>


*This post is locked for comments

I have the same question (0)
  • Hemant Kumar Sahu Profile Picture
    1,829 on at

    Hi Mudassar Hassa,

    You can't compare two fields in FetchXML you can compare with values.

    But you can assign 'enity1_datecreated' to a variable and then add 5day.

    it should be

    var dateCreated= //enity1_datecreated get the value + 5days

    Hope this helps you !

    Hemant

  • Community Member Profile Picture
    on at

    Hi,

    The easiest way is to create your exact query with "Advance find" and then download the fetchXML.

  • Community Member Profile Picture
    on at

    I know the way to generate the fetchXML, but the question is can I used the parent attribute in the linked-entity value filter?

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    1,829 on at

    Mudassar Hassan,

    You can not compare two fields in fetch xml.

    Hemant

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi Mudassar,

     +1 for Hemant, but you might try doing this:

    - Create a calculated field on the child entity (DATEDIFF between parent.createdOn and entity.createdOn)

    - In your fetchXml, add a condition for that new calculated field (equals 5)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans