Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum

Date Filter use

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

Could anyone please tell me how to use date filter in Business Central in a report request page ?

I have to create a report to display Birthdays falling between a specified range.

Following is the Report code :

report 50101 EmployeeBirthdayReport
{
    Caption = 'Employee Birthday';
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    RDLCLayout = 'EmployeeBirthdayReport.rdl';

    dataset
    {
        dataitem("Employee"; Employee)
        {
            RequestFilterHeading = ' ';
            RequestFilterFields = "Office Location", "status", "Date Filter";

            column(No_; "No.")
            {

            }

            column(First_Name; "First Name")
            {

            }
            column(Last_Name; "Last Name")
            {

            }
            column(Birth_Date; "Birth Date")
            {

            }
        }
    }
The required filters are 'From Date' and 'To Date'/ Please modify the code accordingly.
Thanks !
Categories:
  • Verified answer
    ChazKimRP Profile Picture
    380 on at
    RE: Date Filter use

    You would put it in the dataitem properties. Here is an example to sort invoices by No.

           dataitem(Header;"Sales Invoice Header")

           {

               DataItemTableView = SORTING("No.");

               RequestFilterFields = "No.","Sell-to Customer No.","No. Printed";

               RequestFilterHeading = 'Posted Sales Invoice';

    Please mark the answer as verified after reviewing.

    Thanks!

    -Chaz

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Date Filter use

    One more thing, I have to apply sorting in the report i.e. report should be sorted in ascending order on date of birth. I tried orderby property, where to apply this property ? It is not getting accepted on the report code.

  • Verified answer
    ChazKimRP Profile Picture
    380 on at
    RE: Date Filter use

    Hello,

    You may have to tinker around with the snippet below. But this should get you towards what you are looking for. Two variables of type date, that are put on the request page when you run the report. Based on what the user puts in there, onaftergetrecord trigger sets range to filter the records only within that range.

    report 50101 EmployeeBirthdayReport

    {

       Caption = 'Employee Birthday';

       UsageCategory = ReportsAndAnalysis;

       ApplicationArea = All;

       DefaultLayout = RDLC;

       RDLCLayout = 'EmployeeBirthdayReport.rdl';

       dataset

       {

           dataitem("Employee"; Employee)

           {

               RequestFilterHeading = ' ';

               RequestFilterFields = "Office Location", "status", "Date Filter";

               column(No_; "No.")

               {

               }

               column(First_Name; "First Name")

               {

               }

               column(Last_Name; "Last Name")

               {

               }

               column(Birth_Date; "Birth Date")

               {

               }

               trigger OnAfterGetRecord();

               begin

                   SetRange("Birth Date",FromDate,ToDate);

               end;

           }

       requestpage

       {

           layout

           {

               area(Content)

               {

                   group(GroupName)

                   {

                       field(FromDate;FromDate)

                       {

                           ApplicationArea = All;

                       }

                       field(ToDate;ToDate){ApplicationArea=ALL;}

                   }

               }

           }

       }

       var

       FromDate: Date;

       ToDate: Date;

      }

    Please verify this answer

    Thanks!

    -Chaz

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Date Filter use

    I didn't find any report like that till now. Would you be able to make changes in the code snippet I provided?

  • Suggested answer
    ChazKimRP Profile Picture
    380 on at
    RE: Date Filter use

    Praveen,

    You can simply just have the date field filter on the request page be 3/12/2019..3/15/2019 this would show you only records within those dates. Or you can use the pipe sine "|" for specific values. Less customization is always better.

    If you truly want to two fields check out the code behind a report that already has that, you will need to create some variables, and the setfilter for the report.

    Thanks,

    -Chaz Kim

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans