Skip to main content

Notifications

Community site session details

Community site session details

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

Reports groups in Business central

(0) ShareShare
ReportReport
Posted on by 305

Hi

I have a report in which I need to group the records on the basis of Employee No. I have a problem in the report such that two columns 'Department' and 'Office Location' from Employee dataitem displays the values tagged with the first employee of the report for all the other employees as well. These should however be corresponding to each employee. Below is the code: 

report 50109 "Employee - Staff Absence"
{
    // version NAVW113.00,NAVNA13.00

    DefaultLayout = RDLC;
    RDLCLayout = './Employee - Staff Absences.rdl';
    ApplicationArea = All;
    Caption = 'Staff Absences';
    UsageCategory = ReportsAndAnalysis;

    dataset
    {
        dataitem(Employee1; Employee)
        {
            RequestFilterFields = "Office Location", "Status", "Department";
            // DataItemLink = "No." = field("Employee No.");
            PrintOnlyIfDetail = true;



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

                //  dataitem(Employee1; Employee)
                // {
                //      RequestFilterFields = "Office Location", "Status", "Department";
                //      DataItemLink = "No." = field("Employee No.");

                column(FORMAT_TODAY_0_4_; Format(Today, 04))
                {
                }
                column(COMPANYNAME; COMPANYPROPERTY.DisplayName)
                {
                }
                column(CurrReport_PAGENO; CurrReport.PageNo)
                {
                }
                column(Employee_Absence__TABLECAPTION__________AbsenceFilter; TableCaption + ': ' + AbsenceFilter)
                {
                }
                column(AbsenceFilter; AbsenceFilter)
                {
                }
                column(EmployeeFilter; EmployeeFilter)
                {
                }
                column(Employee_Absence__Employee_No__; "Employee Absence"."Employee No.")
                {
                }
                column(Employee_FullName; Employee.FullName)
                {
                }
                column(Employee_Absence__From_Date_; Format("Employee Absence"."From Date"))
                {
                }
                column(Employee_Absence__To_Date_; Format("Employee Absence"."To Date"))
                {
                }
                column(Employee_Absence__Cause_of_Absence_Code_; "Employee Absence"."Cause of Absence Code")
                {
                }
                column(Employee_Absence_Description; "Employee Absence".Description)
                {
                }
                column(Employee_Absence_Quantity; "Employee Absence".Quantity)
                {
                }
                column(Employee_Absence__Unit_of_Measure_Code_; "Employee Absence"."Unit of Measure Code")
                {
                }
                column(Employee___Staff_AbsencesCaption; Employee___Staff_AbsencesCaptionLbl)
                {
                }
                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__Cause_of_Absence_Code_Caption; FieldCaption("Cause of Absence Code"))
                {
                }
                column(Employee_Absence_DescriptionCaption; FieldCaption(Description))
                {
                }
                column(Employee_Absence_QuantityCaption; FieldCaption(Quantity))
                {
                }
                column(Employee_Absence__Unit_of_Measure_Code_Caption; FieldCaption("Unit of Measure Code"))
                {
                }
                column(Office_Location; Employee1."Office Location")
                {

                }
                column(Department; Employee1.Department)
                {

                }

                trigger OnAfterGetRecord()
                begin
                    Employee.Get("Employee No.");
                    // Clear(EmpLoc);
                    // Clear(EmpDep);
                    // if Employee.Get("Employee No.") then begin
                    //     // EmpLoc := Employee."Office Location";
                    //     EmpDep := format(Employee.Department);
                    // end;
                end;




            }

        }
    }

    requestpage
    {

        layout
        {
        }
        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
        AbsenceFilter := "Employee Absence".GetFilters;
        EmployeeFilter := Employee1.GetFilters;
    end;

    var
        Employee: Record Employee;
        AbsenceFilter: Text;
        EmployeeFilter: Text;
        Employee___Staff_AbsencesCaptionLbl: Label 'Employee - Staff Absences';
        CurrReport_PAGENOCaptionLbl: Label 'Page';
        Employee_Absence__From_Date_CaptionLbl: Label 'From Date';
        Employee_Absence__To_Date_CaptionLbl: Label 'To Date';

}


Please help.
Regards,
Khudeja

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 858

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 569

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans