web
You’re offline. This is a read only version of the page.
close
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:
I have the same question (0)
  • Suggested answer
    ChazKimRP Profile Picture
    380 on at

    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

  • Dynamics 365 Business Central Profile Picture
    700 on at

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

  • Verified answer
    ChazKimRP Profile Picture
    380 on at

    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

    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

    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

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 > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans