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 :
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 :
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
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.
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
I didn't find any report like that till now. Would you be able to make changes in the code snippet I provided?
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
André Arnaud de Cal...
293,278
Super User 2025 Season 1
Martin Dráb
232,011
Most Valuable Professional
nmaenpaa
101,156
Moderator