Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

RequestFilterFields issue

Posted on by 670

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.

  • Nick Webb Profile Picture
    Nick Webb 670 on at
    RE: RequestFilterFields issue

    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];
    

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: RequestFilterFields issue

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans