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

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans