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 filter current form data based on financial year

(0) ShareShare
ReportReport
Posted on by 327

i have table data like this 

`3463.Capture.PNG

its Holiday master table i have created separate form for end use if he open the form it should show current year holidays,how i can filter data in init method....in that table 2 fields are there that is belongs to financial year starting date and ending date ..yearname field is financial year.if open form today only it should show 2nd record because that holliday date is presented in the financial year 2017-18.how can i achieve this..

thanks in advance.....

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    How are you tracking your financial holidays, if you have made the setup using Working time calenders then use the below code which shows all the holidays(both financial and weekends).

    WorkTimeCalendar:

    2146.Calendar.jpg

    Path: Init method of the formdatasource.

    You can replace sampleTable with your custom Table.

    public void init()
    {
        WorkCalendarTable workCalendarTable;
        WorkCalendarDate workCalendarDate;
        QueryBuildDataSource qbds, qbdsWorkCalendar, qbdsTable;
        
        super();
    
        qbds = this.query().dataSourceTable(tableNum(SampleTable));
        qbdsWorkCalendar = qbds.addDataSource(tableNum(WorkCalendarDate));
        qbdsWorkCalendar.addLink(fieldNum(SampleTable, date), fieldNum(WorkCalendarDate, TransDate));
        qbdsWorkCalendar.joinMode(JoinMode::InnerJoin);
        
        SysQuery::findOrCreateRange(qbdsWorkCalendar, fieldNum(WorkCalendarDate, WorkTimeControl)).value(queryValue(WorkTimeControl::Closed));
        
        qbdsTable =  qbdsWorkCalendar.addDataSource(tableNum(workCalendarTable));
        qbdsTable.addLink(fieldNum(WorkCalendarDate, CalendarId), fieldNum(workCalendarTable, CalendarId));
        qbdsTable.joinMode(JoinMode::InnerJoin);
        
       // SysQuery::findOrCreateRange(qbdsTable, fieldNum(workCalendarTable, //CalendarId)).value(queryValue("XYZ")); // Specify calender Id here
    }
  • Suggested answer
    Israel Gonzalez Profile Picture
    746 on at

    Hi Karthik143, you can create a query and there filter what you need, later you put in grid.

  • karthik143 Profile Picture
    327 on at

    hi mr.cheitanya thanks for immediate response.i am not using any fiscal calendar setup

    i am entering holidays data in my custom table  

  • karthik143 Profile Picture
    327 on at

    thanks for your suggetion  mr.sukrut i have not yet followed once it is done ill let you know

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    When you say custom table, are you storing all the data in Holiday master table and want to show the records which has only holiday.

  • karthik143 Profile Picture
    327 on at

    Hi Mr.cheitanya  now i have changed my requirement using working calendar setup

    i have given all my holidays list in that setup.

    now i have created one button in my form if click that it should current financial year holidays in another form..how i can achieve this...

    Thanks in advance...

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi Karthik,

    Please follow below steps
    (i) Pass the values from Parent Form to your holiday form, if you want to filter any data on holiday form based on Parent form record.
    Refer this links to pass the values between forms:

    (Passing Arguments from One Form to Another Form in AX 2012)

    http://axguruu.blogspot.com/2014/06/passing-arguments-from-one-form-to.html

    (ii) In the init method of holiday formdatasource, use the same code I sent earlier by adding the range from Parent form like below. Replace SamplTable with your Holiday Table.

    If anything is not clear, send me about your parent table and holiday table details(like the fields and what they are storing) will provide you the code.

    public void init()
    {
        WorkCalendarTable workCalendarTable;
        WorkCalendarDate workCalendarDate;
        QueryBuildDataSource qbds, qbdsWorkCalendar, qbdsTable;
        ParentTable parentTable;
        str _parmid;
        
        super();
    
        parentTable = element.args().record();
        _parmid= element.args().parm();
        
        qbds = this.query().dataSourceTable(tableNum(SampleTable));
        qbdsWorkCalendar = qbds.addDataSource(tableNum(WorkCalendarDate));
        qbdsWorkCalendar.addLink(fieldNum(SampleTable, date), fieldNum(WorkCalendarDate, TransDate));
        qbdsWorkCalendar.joinMode(JoinMode::InnerJoin);
    
        SysQuery::findOrCreateRange(qbdsWorkCalendar, fieldNum(WorkCalendarDate, WorkTimeControl)).value(queryValue(WorkTimeControl::Closed));
    
        qbdsTable =  qbdsWorkCalendar.addDataSource(tableNum(workCalendarTable));
        qbdsTable.addLink(fieldNum(WorkCalendarDate, CalendarId), fieldNum(workCalendarTable, CalendarId));
        qbdsTable.joinMode(JoinMode::InnerJoin);
    
        //SysQuery::findOrCreateRange(qbdsTable, fieldNum(workCalendarTable, CalendarId)).value(queryValue("XYZ")); // Specify calenderId here
        //SysQuery::findOrCreateRange(qbdsTable, fieldNum(SampleTable, CalendarId)).value(queryValue(_parmid)); // Specify range from ParentForm
    }



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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans