Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXML linked entity filter based on parent entity

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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
    ashlega 34,475 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
    Hemant Kumar Sahu 1,825 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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Hemant Kumar Sahu 1,825 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

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans