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

How to initialize a form by grouping by a field

(0) ShareShare
ReportReport
Posted on by 325

Hi Everyone,

I want to initialize a Form by grouping by a field. Example in the below form I want to initialize by grouping Absence code field. Please help me how to achieve this. 

groupby.PNG

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,679 Super User 2026 Season 1 on at

    Each form has query, you can Group by using any field.

    Modify your query and re-drag fields on design.

  • Ravikumar Profile Picture
    325 on at

    Thanks for your reply Sohaib,

    can you give me an example code?

  • Sohaib Cheema Profile Picture
    49,679 Super User 2026 Season 1 on at

    Hi,

    have a look at next post,

    msdn.microsoft.com/.../hh745337.aspx

    When you create an AOT query, you can add a field in group by node.

    After that you can add only required fields of adding all fields, under field nodes of query Datasource.

    is that a customized or existing  form?

  • Suggested answer
    XB Profile Picture
    1,875 on at

    in the init method of your datasource (on your form) after super set something like

    this.query().datasourceTable(tablenum(YourDataSource)).addGroupByField(fieldnum(yourtable, yourgroupfield));

    the problem with this is that some fields couldn't by grouped, for example on your firsts rows

    1.-StickLeave  40

    2.-StickLeave

    when grouped the result will be

    1.-StickLeave

    and your last fiels do they have to be sum?

  • Ravikumar Profile Picture
    325 on at

    its a customized form

  • Ravikumar Profile Picture
    325 on at

    Hi Javier,

    Yes your are right...  the last two fields should be sum...  

    ex: sum of the "hours taken" by sick leave

  • Verified answer
    XB Profile Picture
    1,875 on at

    THen you need add more lines like

    this.query().datasourceTable(tablenum(YourDataSource)).addSelectionField(fieldnum(yourtable, yourgroupfield), SelectionField::Sum);

    and repeat line for each sum field

  • Ravikumar Profile Picture
    325 on at

    thanks Javier, its worked

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

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans