Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXML - Only display the records that have the following criterias - is it possible?

(0) ShareShare
ReportReport
Posted on by 880

Hi,

Is it possible to create a fetchXML that will only display records per day (crm_date) where the count of crm_flag1 and crm_flag 2 that is set to yes is greater than or equal to 4? Also it should take the date into condiseration when performing the logic. So the logic is run per date. The entity name is crm_timeregistrations. 

Record set 1
This will display the first 2 records. It will be displayed because on 07-01-2019 there is 2 x crm_flag1=yes and 2 x crm_flag2 = yes. So in total 4 x yes for 07-01-2019. Record 3 will not be displayed because it's another date and there is less than 4 yes. 

crm_date: 07-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 07-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 08-01-2019, crm_flag1=no, crm_flag2 = no

Record set 2
Nothing will be dispalyed. There is only 1 x crm_flag1= yes and 1 x crm_flag2 = yes. So in total 2 x yes. 

crm_date: 09-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 09-01-2019, crm_flag1=no, crm_flag2 = no
crm_date: 10-01-2019, crm_flag1=no, crm_flag2 = no

*This post is locked for comments

  • Martin Donnelly Profile Picture
    Martin Donnelly 1,010 on at
    RE: FetchXML - Only display the records that have the following criterias - is it possible?

    ...of course, that being said, you may be able to build your filter expression dynamically in jscript and apply it to your sub-grid -- formContext.getControl("nameOfGridControl").addCustomView()

  • Martin Donnelly Profile Picture
    Martin Donnelly 1,010 on at
    RE: FetchXML - Only display the records that have the following criterias - is it possible?

    I'm with Guido.  You can do aggregate fetches but, you can't combine list and aggregation; you can't use an aggregated value in a filter statement.  Nor can you send a variable to a TOP specification.

    Fetch works only with hierarchical joins.  There is no notion of the SQL joining to a "sub-select".  You show no relationship between your two entities.

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,069 Super User 2024 Season 1 on at
    RE: FetchXML - Only display the records that have the following criterias - is it possible?

    imho is not possible, you can't count the occurrences before showing the results and there isn't a fetchxml operator to allow that

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans