Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum

Report filtering issue

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

I have created a report using two dataitems, filters are also used from both of them. But, when 'Date' (Comment date from and Comment date to) filters are not applied, then data from second dataitem is not getting displayed. On the other hand, if 'Date' (Comment date from and Comment date to) filters are applied, then it is displaying correct data.

How to overcome this issue, please suggest !

Thanks !

Please refer the below code :-

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, 04))
                {
                }
                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 := Employee.GetFilters;
                    HumanResourceCommentLineFilter := "Human Resource Comment Line".GetFilters;

                end;

                trigger OnAfterGetRecord()

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

                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;


    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;

}


Categories:
  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Report filtering issue

    Hi Tero,

    The above issue got solved. But I am facing one more issue i.e. the Date (Comment Date From and Comment Date To) filters are not working properly. For example, the data beyond the mentioned range is also getting displayed. Do you have any clue to solve this ? I have shared the source code too.

    Please try to help at the earliest.

  • Community Member Profile Picture
    on at
    RE: Report filtering issue

    That would be my first guess. I just don't have a test case.

    Tero

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Report filtering issue

    No, would this work ?

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Report filtering issue

    Have you tried not applying the filter if the dates are empty:

    IF (CommentDateFrom <> 0D) and (CommentDateTo <> 0D) then 

          SetRange(Date, CommentDateFrom, CommentDateTo);

    Tero

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans