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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Headers in Report

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

I have created a report in which Comments have to be displayed for corresponding employees in a particular date range.

The issue is that, whenever I mention the wrong duration of date (i.e. the date range in which there are no comments registered) then, some of the headers in the report (those which are mentioned in the dataitems) do not appear in the report.

Is there any way to display all the headers even if there is no data appearing in the report ?

Screenshot of report :-

pastedimage1570695632562v1.png

Expected report (headers):-

pastedimage1570695791223v2.png

Below is the code for reference :-

report 50104 EmployeeComments
{
    Caption = 'Comments';
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    RDLCLayout = 'EmployeeComments.rdl';

    dataset

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

            PrintOnlyIfDetail = true;

            // DataItemTableView = where ("Table Name" = filter (Employee));

            dataitem("Human Resource Comment Line"; "Human Resource Comment Line")
            {
                DataItemLink = "No." = field ("No.");
                RequestFilterFields = Comment_Type;

                column(FORMAT_TODAY_0_4_; Format(Today, 0, 4))
                {
                }
                column(COMPANYNAME; COMPANYPROPERTY.DisplayName)
                {
                }
                // column(CurrReport_PAGENO; CurrReport.PageNo)
                // {
                // }
                column(No_; "No.")
                {
                }

                column(EmpFirstName; EmpFirstName)
                {
                }

                column(EmpLastName; EmpLastName)
                {
                }

                column(EmpLoc; Employee."Office Location")
                {
                }

                column(Comment_Type; Comment_Type)
                {
                }

                column(Date; format(Date))
                {
                }

                column(Comment; Comment)
                {
                }
                column(NoFilter; NoFilter)
                {
                }
                column(CommentTypeFilter; CommentTypeFilter)
                {
                }
                column(CommentDateFromFilter; CommentDateFromFilter)
                {
                }
                column(EmployeeFilter; EmployeeFilter)
                {
                }
                column(HumanResourceCommentLineFilter; HumanResourceCommentLineFilter)
                {
                }


                // dataitem(Employee; Employee)
                // {
                //     RequestFilterHeading = '';
                //     RequestFilterFields = "Office Location", "Status";
                //     DataItemLinkReference = "Human Resource Comment Line";
                //     DataItemLink = "No." = field ("No.");
                // }


                trigger OnPreDataItem()

                var

                    myInt: Integer;

                begin

                    SetRange(Date, CommentDateFrom, CommentDateTo);
                    EmployeeFilter := Employee1.GetFilters;
                    HumanResourceCommentLineFilter := "Human Resource Comment Line".GetFilters;



                end;

                trigger OnAfterGetRecord()

                begin
                    // IF (CommentDateFrom <> 0D) and (CommentDateTo <> 0D) then begin
                    //     SetRange(Date, CommentDateFrom, CommentDateTo);
                    // end;

                    Clear(EmpFirstName);
                    Clear(EmpLastName);
                    Clear(EmpLoc);
                    if Employee.Get("No.") then begin
                        EmpFirstName := Employee."First Name";
                        EmpLastName := Employee."Last Name";
                        EmpLoc := Employee."Office Location";
                    end;
                    //SetRange(Date, CommentDateFrom, CommentDateTo);
                end;
            }
        }
    }

    requestpage

    {

        layout

        {
            area(Content)

            {

                field("Comment Date From"; CommentDateFrom)

                {

                    ApplicationArea = all;
                    ShowMandatory = true;

                    // trigger OnValidate()
                    // var
                    //     myInt: Integer;

                    // begin

                    //     if Format(CommentDateFrom) = ' ' then begin
                    //         Error('Value required');
                    //     end;
                    // end;

                }

                field("Comment Date To"; CommentDateTo)

                {

                    ApplicationArea = all;
                    ShowMandatory = true;

                }

            }

        }

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


    }
    // trigger OnPreReport()
    // var
    //     myInt: Integer;
    // begin
    //     NoFilter := Employee.GetFilters;
    //     CommentTypeFilter := "Human Resource Comment Line".GetFilters;
    //     CommentDateFromFilter := "Human Resource Comment Line".GetFilters;
    // end;
    trigger OnPreReport()             //making start and end dates mandatory
    var
        myInt: Integer;
    begin
        if (CommentDateFrom = 0D) OR (CommentDateTo = 0D) then begin
            Error('Start date and End date is mandatory');
        end;

    end;


    var

        CurrReport_PAGENOCaptionLbl: Label 'Page';
        CommentDateFrom: Date;
        CommentDateTo: Date;
        HumanResource: Record "Human Resource Comment Line";
        Employee: Record Employee;
        EmpFirstName: Text;
        EmpLastName: Text;
        EmpLoc: Code[50];
        NoFilter: Text;
        CommentTypeFilter: Text;
        CommentDateFromFilter: Text;
        EmployeeFilter: Text;
        HumanResourceCommentLineFilter: Text;
        status: Text;
        commentType: Code[50];

}


  • Dynamics 365 Business Central Profile Picture
    700 on at

    Could anyone please guide, if possible ?

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hi Praveen,

    You can make use of CurrReport.SKIP when comment is not present in OnAfterGetRecord trigger for the Employee table.

  • Dynamics 365 Business Central Profile Picture
    700 on at

    trigger OnAfterGetRecord()

               var

                   myInt: Integer;

               begin

                   if (commentType = '') and (format(Comment) = '') and ("Human Resource Comment Line".Date = 0D) then

                       CurrReport.Skip();

               end;

    Please check it it is correct !

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Yes it looks correct to me...

    I believe the logic should be

    If Comment = '' then

    CurrReporr.Skip();

  • Dynamics 365 Business Central Profile Picture
    700 on at

    It didn't work actually

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Did you understand the requirement clearly or should I explain it again?

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Please repeat once as to what exactly are you trying to do in this report.

    I think you need to set PrintOnlyifDetail

    = false

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hi,

    You can create a new DataItem and not use any DataItemLink for it. Created variables and put those variables as columns under the newdataitem.

    If you need any help you can call me or email me.

  • Dynamics 365 Business Central Profile Picture
    700 on at

    What would be the name of the new dataitem ? Basically, dataitem is the name of a table. So, which table should be used ?

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

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 671 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 434 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 241 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans