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 :
Small and medium business | Business Central, N...
Suggested Answer

Report filtering

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

In a report I created using 3 dataitems, one of the filters (CODE filter from ENTITLEMENTS dataitem) is not working properly. The data which is not required is also getting displayed.

Could anyone please figure out why is it happening ?

Thanks !

Below is the AL code for reference -

report 50130 "Emp-AbsencebyEntitlementPeriod"
{

    RDLCLayout = './Employee - Absences by Entitlement Period.rdl';
    ApplicationArea = All;
    Caption = 'Absence By Entitlement Period';
    UsageCategory = ReportsAndAnalysis;

    dataset
    {
        dataitem(Employee1; Employee)
        {
            RequestFilterFields = Location, Status, "Department";
            // column(FORMAT_TODAY_0_4_; Format(Today, 0, 4))
            // {
            // }
            // column(COMPANYNAME; COMPANYPROPERTY.DisplayName)
            // {
            // }

            dataitem("Employee Absence"; "Employee Absence")
            {
                DataItemLink = "Employee No." = field("No.");
                DataItemTableView = SORTING("Cause of Absence Code", "From Date");
                RequestFilterFields = "Employee No.";


                column(FORMAT_TODAY_0_4_; Format(Today, 04))
                {
                }
                column(COMPANYNAME; COMPANYPROPERTY.DisplayName)
                {
                }

                // column(CurrReport_PAGENO; CurrReport.PageNo)
                // {
                // }
                column(EmployeeAbsenceFilter; EmployeeAbsenceFilter)
                {
                }
                column(Employee_Absence_Description; Description)
                {
                }
                column(Employee_Absence__Cause_of_Absence_Code_; "Cause of Absence Code")
                {
                }
                column(Employee_Absence__From_Date_; Format("From Date"))
                {
                }
                column(Employee_Absence__To_Date_; Format("To Date"))
                {
                }
                column(Employee_Absence__Quantity__Base__; "Quantity (Base)")
                {
                }
                column(HumanResSetup__Base_Unit_of_Measure_; HumanResSetup."Base Unit of Measure")
                {
                }
                column(Employee_Absence__Employee_No__; "Employee No.")
                {
                }
                column(Employee_FullName; Employee.FullName)
                {
                }
                column(Employee_FirstName; Employee."First Name")
                {
                }
                column(Employee_Surname; Employee."Last Name")
                {
                }
                column(TotalAbsence; TotalAbsence)
                {
                    DecimalPlaces = 0 : 2;
                }
                column(Employee___Absences_by_CausesCaption; Employee___Absences_by_CausesCaptionLbl)
                {
                }
                column(CurrReport_PAGENOCaption; CurrReport_PAGENOCaptionLbl)
                {
                }
                column(Employee_Absence__From_Date_Caption; Employee_Absence__From_Date_CaptionLbl)
                {
                }
                column(Employee_Absence__To_Date_Caption; Employee_Absence__To_Date_CaptionLbl)
                {
                }
                column(Employee_Absence__Employee_No__Caption; FieldCaption("Employee No."))
                {
                }

                column(Employee_Absence__Quantity__Base__Caption; FieldCaption("Quantity (Base)"))
                {
                }

                column(Employee_EmpDate; Employee."Employment Date")
                {
                }
                column(DaysAbsent; DaysAbsent)
                {
                }
                column(Emp_Department; Employee.Department)
                {
                }
                column(AbsenceDescription; AbsenceDescription)
                {

                }
                dataitem(Entitlements; Entitlements)
                {
                    DataItemLink = Employee_No = field("Employee No.");
                    RequestFilterFields = "Code";

                    DataItemTableView = sorting(Code);


                    column(Starting_Period; Starting_Period)
                    {

                    }
                    column(Ending_Period; Ending_Period)
                    {

                    }
                    column(Days; Days)
                    {

                    }
                    column(Additional_Entitlements; Additional_Entitlements)
                    {

                    }
                    column(DaysAbsentUpdated; DaysAbsent)
                    {

                    }
                    column(AvailableEnitilement; AvailableEnitilement)
                    {

                    }
                    column(EmployeeFilter; EmployeeFilter)
                    {

                    }

                    trigger OnPreDataItem()
                    begin
                        EmployeeFilter := Employee1.GetFilters();
                        EmployeeAbsenceFilter := "Employee Absence".GetFilters();
                        //Entitlements.SetFilter(Code, '%1', CodeVar);
                    end;


                    trigger OnAfterGetRecord()
                    begin
                        Clear(DaysAbsent);
                        Clear(AvailableEnitilement);
                        EmpAbsenceRec.Reset();
                        EmpAbsenceRec.SetRange("Employee No.", Employee_No);
                        EmpAbsenceRec.SetRange("Entitlement Code", Code);
                        if EmpAbsenceRec.FindSet() then
                            repeat
                                DaysAbsent += EmpAbsenceRec."Quantity (Base)";
                            until EmpAbsenceRec.Next() 0;


                        AvailableEnitilement := Additional_Entitlements + Days - DaysAbsent;
                        FindFirst();
                    end;

                }

                trigger OnAfterGetRecord()
                begin
                    Clear(Emp_Department);
                    Clear(AbsenceDescription);

                    Employee.Get("Employee No.");
                    TotalAbsence := TotalAbsence + "Quantity (Base)";
                    DefaultDimension.Reset();
                    DefaultDimension.SetRange("Table ID", 5200);
                    DefaultDimension.SetRange("Dimension Code", 'DEPARTMENT');
                    DefaultDimension.SetRange("No.", "Employee No.");
                    IF DefaultDimension.Findset() then begin

                        Emp_Department := DefaultDimension."Dimension Value Code";
                    END;
                    CauseofAbsenceRec.Reset();
                    CauseofAbsenceRec.SetRange(Code, "Cause of Absence Code");
                    IF CauseofAbsenceRec.FindFirst() then begin
                        AbsenceDescription := CauseofAbsenceRec.Description;
                    end;

                end;

            }

        }


    }

    requestpage
    {

        layout
        {
            // area(Content)
            // {
            //     group(Entitlements)
            //     {
            //         field(CodeVar; CodeVar)
            //         {
            //             ApplicationArea = All;
            //             Caption = 'Code';
            //             trigger OnDrillDown()
            //             var
            //                 Entitlements: Record Entitlements;
            //                 Page_Entitlements: Page Entitlements;
            //             begin
            //                 Page_Entitlements.SETTABLEVIEW(Entitlements);
            //                 Page_Entitlements.LOOKUPMODE(TRUE);
            //                 IF Page_Entitlements.RUNMODAL = ACTION::LookupOK THEN BEGIN
            //                     Page_Entitlements.GETRECORD(Entitlements);
            //                     "CodeVar" := Entitlements.Code;
            //                 end;
            //             end;

            //         }
            //     }
            // }
        }
        trigger Onopenpage()                   //sets default value for the Status filter as 'Active'
        var
            myInt: Integer;
        begin
            Employee1.SetRange(Status, Employee1.Status::Active);
        end;

        // actions
        // {
        // }
    }

    labels
    {
    }

    // trigger OnPreReport()
    // begin
    //     LocationFilter := Employee.GetFilters;
    //     EmployeeNoFilter := "Employee Absence".GetFilters;
    //     EmployeeAbsenceFilter := "Employee Absence".GetFilters;
    //     HumanResSetup.Get;
    //     HumanResSetup.TestField("Base Unit of Measure");
    // end;

    var
        Employee: Record Employee;
        EmpAbsenceRec: Record "Employee Absence";
        CauseofAbsenceRec: Record "Cause of Absence";
        Emp_Department: Code[30];
        AbsenceDescription: Text;
        DefaultDimension: Record "Default Dimension";
        HumanResSetup: Record "Human Resources Setup";
        EmployeeAbsenceFilter: Text;
        TotalAbsence: Decimal;
        Employee___Absences_by_CausesCaptionLbl: Label 'Employee - Absences by Causes';
        CurrReport_PAGENOCaptionLbl: Label 'Page';
        Employee_Absence__From_Date_CaptionLbl: Label 'From Date';
        Employee_Absence__To_Date_CaptionLbl: Label 'To Date';
        Full_NameCaptionLbl: Label 'Full Name';
        HumanResSetup__Base_Unit_of_Measure_CaptionLbl: Label 'Base Unit of Measure';
        Total_AbsenceCaptionLbl: Label 'Total Absence';
        DaysAbsent: Decimal;
        AbsenceReg: Record "Absence";
        AvailableEnitilement: Decimal;
        EmployeeFilter: Text;
    //CodeVar: code[30];


}



I have the same question (0)
  • Suggested answer
    Olister Rumao Profile Picture
    3,967 on at

    Hi Praveen,

    Can you provide details as to what exactly you are trying to accomplish in this report?

    I think Entitlement is related Employee and not Employee Leave record.

    So your dataitem structure should be and triggers will be as always

    Employee

    -- Employees Leave

    -- Entitlement

        OnPreDataItem()

       {

           Entitlement.Setrange( Code,CodeVar)

        }

    Let me know if this works

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans