Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    ashlega Profile Picture
    34,477 on at
    RE: FetchXML linked entity filter based on parent entity

    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)

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    1,829 on at
    RE: FetchXML linked entity filter based on parent entity

    Mudassar Hassan,

    You can not compare two fields in fetch xml.

    Hemant

  • Community Member Profile Picture
    on at
    RE: FetchXML linked entity filter based on parent entity

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

  • Community Member Profile Picture
    on at
    RE: FetchXML linked entity filter based on parent entity

    Hi,

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

  • Hemant Kumar Sahu Profile Picture
    1,829 on at
    RE: FetchXML linked entity filter based on parent entity

    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

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Scott_itD Profile Picture

Scott_itD 3 Community Manager

#2
Aiden Kaskela Profile Picture

Aiden Kaskela 2

#2
MikeC282 Profile Picture

MikeC282 2

Featured topics

Product updates

Dynamics 365 release plans