Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

Filtered Field in Report Request Page Based on Custom Criteria in Business Central

Khushbu Rajvi. Profile Picture Khushbu Rajvi. 14,462 Super User 2025 Season 1

Sometimes, you may have a requirement to add a custom filter on the request page of a report. For example, if the user selects a specific field, the report should only show data where the values in that field start with "Abc". Only when the user selects this filter should the data in the report be filtered accordingly.

I have created a custom customer report. For the Location Code field, I have set a condition to filter the data: only records where the Location Code starts with "ABC" should be available for filtering. When the user selects this field on the request page, only the filtered data (i.e., Location Codes starting with "ABC") should appear in the lookup. Once the user selects a value, the report should display data based on this filtered selection.

Code: 

report 50710 Customerr

{
UsageCategory = ReportsAndAnalysis;
ApplicationArea = All;
Caption = 'Customer Report';
DefaultRenderingLayout = LayoutName;

dataset
{
dataitem(Customer; Customer)
{
column(ColumnName; "No.")
{

}
column(Name; Name)
{

}
column(Address; Address)
{

}
column(Location_Code; "Location Code")
{
}
trigger OnPreDataItem()
begin
if LocationFilter <> '' then
SETRANGE("Location Code", LocationFilter)
else
CLEAR("Location Code");
end;
}
}

requestpage
{
AboutTitle = 'Teaching tip title';
AboutText = 'Teaching tip content';
layout
{
area(Content)
{
group(GroupName)
{
field(Filter; LocationFilter)
{
ApplicationArea = All;

TableRelation = Location.Code WHERE(Code = FILTER('ABC*'));
}
}
}
}
}

rendering
{
layout(LayoutName)
{
Type = RDLC;
LayoutFile = 'mySpreadsheet.rdl';
}
}

var
LocationFilter: text;
}

OutPut: 




Thanks For Reading...!!

Regards,
Khushbu Rajvi


This was originally posted here.

Comments

*This post is locked for comments