web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

RequestFilterFields issue

(0) ShareShare
ReportReport
Posted on by 911

I have a report in an AL extension that contains 3 dataitems (as below). There are RequestFilterField lines in each dataitem. The top two, in dataitems: diEmp & diLogSheetLines are working fine but if the third one (in dataitem: diLogSheet) is used the records are not filtered out. The only effect is the field in question is blanked.

Here's the report code:-

report 50052 LogSheetActivityForEmployee
{
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;

    DefaultLayout = RDLC;
    RDLCLayout = 'LogSheetActivityForEmployee.rdl';

    dataset
    {
        dataitem(diEmp; Employee)
        {
            // Sort the table view based on the "No." field.
            DataItemTableView = Sorting("No.");
            // Include the "No." field on the filter tab of the request page.
            RequestFilterFields = "No.";
            // Print data only if at least one of the data items generates output.
            PrintOnlyIfDetail = True;

            column(EmpNo; "No.") { }
            column(FirstName; "First Name") { }
            column(MiddleName; "Middle Name") { }
            column(LastName; "Last Name") { }
            column(ShowDetail; gblnShowDetail) { }
            dataitem(diLogSheetLines; LogSheetLines)
            {
                DataItemLink = ItemEmployeeID = field("No.");
                RequestFilterFields = DateFrom, DateTo;
                column(LogSheetNo; "ParentLogSheetNo.") { IncludeCaption = true; }
                column(DateFrom; DateFrom) { IncludeCaption = true; }
                column(DateTo; DateTo) { IncludeCaption = true; }
                column(Quantity; Quantity) { IncludeCaption = true; AutoFormatType = 0; DecimalPlaces = 2; }
                column(UnitOfMeasure; UnitOfMeasure) { IncludeCaption = true; }
                column(ItemEmployeeID; ItemEmployeeID) { IncludeCaption = true; }
                column(TimeInDays; gdecTimeInDays) { }
                column(TimeInHours; gdecTimeInHours) { }
                column(DaysRunningTotal; gdecDaysRunningTotal) { }
                column(HoursRunningTotal; gdecHoursRunningTotal) { }

                dataitem(diLogSheet; LogSheets)
                {
                    DataItemLink = "LogSheetNo." = field("ParentLogSheetNo.");
                    RequestFilterFields = Customer;                                   // <-- *** THIS LINE DOESN'T WORK !!! ***
                    column(Customer; Customer) { }
                    column(CustomerName; CustomerName) { IncludeCaption = true; }
                }

                trigger OnPreDataItem()
                var
                begin
                end;

                trigger OnAfterGetRecord()
                var
                begin

                    if StrLen(gPreviousEmpNo) = 0 then begin
                        gPreviousEmpNo := ItemEmployeeID;
                    end;

                    if gPreviousEmpNo <> ItemEmployeeID then begin
                        gdecDaysRunningTotal := 0;
                        gdecHoursRunningTotal := 0;
                    end;

                    // NOTE: Running Totals ended up being just for debug purposes

                    case UnitOfMeasure of
                        'DAY':
                            begin
                                gdecTimeInDays := Quantity;
                                gdecTimeInHours := Quantity * 7.5;

                                gdecDaysRunningTotal := gdecDaysRunningTotal   Quantity;
                                gdecHoursRunningTotal := gdecHoursRunningTotal   (Quantity * 7.5);
                            end;
                        'HOUR':
                            begin
                                gdecTimeInHours := Quantity;
                                gdecTimeInDays := Quantity / 7.5;

                                gdecHoursRunningTotal := gdecHoursRunningTotal   Quantity;
                                gdecDaysRunningTotal := gdecDaysRunningTotal   (Quantity / 7.5);
                            end;
                    end;

                    gPreviousEmpNo := ItemEmployeeID;
                end;

                trigger OnPostDataItem()
                var
                begin
                end;
            }
        }
    }

    requestpage
    {
        layout
        {
            area(Content)
            {
                group(Options)
                {
                    Caption = 'Options';
                    field("Show Detail"; gblnShowDetail)
                    {
                        ApplicationArea = Basic, Suite;
                        Caption = 'Show Detail';
                        ToolTip = 'Show Detail';
                        Visible = false;
                    }
                }
            }
        }
        trigger OnOpenPage()
        var
        begin
            gblnShowDetail := true;
        end;
    }

    var
        gdecTimeInDays: Decimal;
        gdecTimeInHours: Decimal;
        gdecDaysRunningTotal: Decimal;
        gdecHoursRunningTotal: Decimal;
        gblnShowDetail: Boolean;
        gPreviousEmpNo: Code[20];
}

Here's a sample RequestPage. The Customer filter at the bottom is not working.

Here's some sample output. The row with the yellow box should've been filtered out as it was for a different customer.

Where am I going wrong? Thanks in advance for help.

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    You need to debug this report, as I just tired so I dont have those tables in system, looks your OnafterGetrecord is not fetching the records.

  • Nick Webb Profile Picture
    911 on at

    In couldn't get the RequestFilterFields working. I think maybe there's an issue when using it with nested dataitems (more than 2 deep)?

    (i.e.) dataitem 1...
                dataitem 2...
                    dataitem 3...
                           RequestFilterFields = ...

    Anyway, I found a workaround. Instead of using RequestFilterFields, I added a combination of an Option and some code in the OnAfterGetRecord event to conditionally skip records, as below:

    group(Options)
    {
        Caption = 'Options';
        field("Customer"; gtxtCustNoFilter)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Customer';
            ToolTip = 'Customer';
            TableRelation = Customer."No.";
        }
    }
    

    trigger OnAfterGetRecord()
    var
        txtCustomer: Code[20];
        bSkipRecord: Boolean;
    begin
        bSkipRecord := false;
        if StrLen(gtxtCustNoFilter) > 0 then begin
            txtCustomer := GetCustomerFromParentLogSheet("ParentLogSheetNo.");
            if txtCustomer <> gtxtCustNoFilter then begin
                bSkipRecord := true;
            end;
        end;
        if bSkipRecord then begin
            CurrReport.Skip();
        end else begin
    
    
    var
        gtxtCustNoFilter: Code[20];
    

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 580 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 462 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 272 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans