Data not displayed properly in report

Hi All,

I have created a report using the tables - Resource, Job, Job Planning Line and Job task.

In the report, the Department, Location and Job Title (from Resource data item) tagged to a particular resource (resource is present on Job Planning Line table) is not properly displayed.

For example, the Job Title for Resource A is getting displayed for all other resources which have other Job titles.

Could anyone please suggest me a solution.

I am attaching the source code for more reference.

Thanks !

Job Task Details Report :-
report 50201 "Job Task Details"
{
    DefaultLayout = RDLC;
    RDLCLayout = 'JobTaskDetails.rdl';
    ApplicationArea = All;
    Caption = 'Job Task Details';
    UsageCategory = ReportsAndAnalysis;

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

            // column(Location; Location) { }
            // column(Department; Department) { }
            // column(Job_Title; Job_Title) { }                              // Task owner designation



            // trigger OnAfterGetRecord()
            // var
            //     myInt: Integer;
            // begin
            //     Employee1.SetFilter("AD user name", Job."Project Manager");
            //     Employee1.SetFilter("Job Title", Job."Project Manager");
            // end;
            // }
            // dataitem(Resource; Resource)
            // {
            //     //DataItemTableView = SORTING("Employee No.", "From Date");
            //     // DataItemLink = "No." = field("No.");
            //     RequestFilterFields = "Employee No.";
            //     PrintOnlyIfDetail = true;
            // }
            dataitem(Job; Job)
            {
                //DataItemLinkReference = Employee;
                //DataItemLink = "No." = FIELD("Employee No.");
                DataItemLink = "Project Manager" = field("Time Sheet Owner User ID");
                RequestFilterFields = "No.", Status, "Bill-to Customer No.";
                PrintOnlyIfDetail = true;

                column(FORMAT_TODAY_0_4_; Format(Today, 0, 4))
                {
                }
                column(COMPANYNAME; COMPANYPROPERTY.DisplayName)
                {
                }
                column(CurrReport_PAGENO; CurrReport.PageNo)
                {
                }
                column(CurrReport_PAGENOCaption; CurrReport_PAGENOCaptionLbl)
                {
                }

                column(Bill_to_Name; "Bill-to Name") { }                      //customer name 
                column(Bill_to_Contact_No_; "Bill-to Contact No.") { }         //customer contact person
                column(No_; "No.") { }                                         //Job Code
                column(Description; Description) { }                           //Job Description
                column(Project_Manager; "Project Manager") { }                 //Job Owner                                                                               //  column(Job_Title; Employee."Job Title") { }
                column(Job_Source; "Job Source") { }                           //Job Source
                column(Projects_type; "Projects type") { }                     //Job type
                column(Role__at_client_firm_; "Role (at client firm)") { }
                column(Clientfilename; Clientfilename) { }                     //Clientfilename
                column(Clientfilenumber; Clientfilenumber) { }
                column(Clientmatternumber; Clientmatternumber) { }
                column(ReceivedDateTime; ReceivedDateTime) { }                 //Date Time Job Received
                column(DueDateTime; DueDateTime) { }                           //Due Date Time
                column(Priority; Priority) { }                                 //Job Priority
                column(Starting_Date; format("Starting Date")) { }                     //Job Starting Date
                column(Ending_Date; format("Ending Date")) { }                         //Job Ending Date
                column(ReturnDateTime; ReturnDateTime) { }                     //Return Date Time
                column(DeadlineRenegotiated; DeadlineRenegotiated) { }
                column(OriginalDueDateTime; OriginalDueDateTime) { }
                column(Status; Status) { }                                     //Job Status
                column(Feedbacktype; Feedbacktype) { }
                column(Comments___from_the_client; "Comments - from the client") { }
                column(ErrorRating; ErrorRating) { }
                column(Comment_from_Exigent; "Comment from Exigent") { }       //Internal Comments

                dataitem("Job Planning Line"; "Job Planning Line")
                {
                    //DataItemLink = "Job Task No." = field("Job No.");
                    DataItemLink = "Job No." = field("No.");

                    //column(Job_Task_No_; "Job Task No.") { }
                    //column(TaskDescription; "Task Description") { }                    //Task Description
                    //column(TaskDescription; Description) { }
                    //column(No; "No.") { }
                    column(No; Description) { }                                          //Name of Employee working on task
                                                                                         //column(Task Owner Designation)
                    column(Quantity; Quantity) { }


                    column(Job_Task_No_; Job_Task_No_) { }
                    column(TaskDescription; TaskDescription) { }                       //Task Description
                    column(Job_Task_Type; Job_Task_Type) { }
                    column(Task_Classification; Task_Classification) { }               //Task Category
                    column(Customer_Work_Type; Customer_Work_Type) { }


                    //Expected Hours To Complete Task

                    //Expected Starting DateTime
                    //Expected Ending DateTime

                    //Actual Starting DateTime
                    //Actual Ending DateTime

                    column(EmpLocation; EmpLocation) { }
                    column(EmpDepartment; EmpDepartment) { }
                    column(EmpJob_Title; EmpJob_Title) { }



                    trigger OnAfterGetRecord()
                    var
                        myInt: Integer;
                    begin
                        Clear(Job_Task_No_);
                        Clear(TaskDescription);
                        Clear(Job_Task_Type);
                        Clear(Task_Classification);
                        Clear(Customer_Work_Type);

                        Rec_JobTask.Reset();
                        Rec_JobTask.SetRange("Job No.", "Job No.");
                        Rec_JobTask.SetRange("Job Task No.", "Job Task No.");

                        if Rec_JobTask.FindFirst then begin

                            Job_Task_No_ := Rec_JobTask."Job Task No.";
                            TaskDescription := Rec_JobTask.Description;
                            Job_Task_Type := format(Rec_JobTask."Job Task Type");
                            Task_Classification := format(Rec_JobTask."Task Classification");
                            Customer_Work_Type := format(Rec_JobTask."Customer Work Type");

                        end
                    end;


                    //  }

                    // }

                    //  }

                    // trigger OnPreDataItem()
                    // var
                    //     myInt: Integer;
                    // begin
                    //     SetRange(ReturnDateTime, FromDate, ToDate);
                    //     //     //Job.SetFilter("Project Manager", UserId);
                    //     //     // Employee.SetFilter("AD user name", "Project Manager");
                    //     //     // Employee.SetFilter("Job Title", "Project Manager");
                    // end;

                }

            }
            trigger OnAfterGetRecord()
            var
                myInt: Integer;
            //Rec_JobPlanningLine: Record "Job Planning Line";
            //Rec_Resource: Record Resource;
            begin
                Clear(EmpLocation);
                Clear(EmpDepartment);
                Clear(EmpJob_Title);

                // Rec_Resource.Reset();
                // Rec_Resource.SetRange("No.", "No.");

                // Rec_Resource.SetRange("No.", Rec_JobTask."Job No.");

                // if Rec_Resource.FindFirst then begin
                if Rec_Resource.get("Employee No.") then begin
                    EmpLocation := Rec_Resource.Location;
                    EmpDepartment := format(Rec_Resource.Department);
                    EmpJob_Title := Rec_Resource."Job Title";
                end;
            end;
        }
    }

    requestpage
    {

        layout
        {
            area(content)
            {
                field(FromDate; FromDate)
                {
                    Caption = 'From Date';
                    ApplicationArea = All;
                }
                field(ToDate; ToDate)
                {
                    Caption = 'To Date';
                    ApplicationArea = All;
                }
            }
        }
        // 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
    //     EmployeeFilter := Employee1.GetFilters;
    // end;

    var
        FromDate: DateTime;
        ToDate: DateTime;
        Employee: Record Employee;
        AbsenceFilter: Text;
        EmployeeFilter: Text;
        CurrReport_PAGENOCaptionLbl: Label 'Page';
        Rec_JobTask: Record "Job Task";
        Rec_JobPlanningLine: Record "Job Planning Line";
        Rec_Resource: Record Resource;
        Job_Task_No_: Code[25];
        TaskDescription: Text;
        Job_Task_Type: Text;
        Task_Classification: Text;
        Customer_Work_Type: Text;
        EmpJob_Title: Text;
        EmpLocation: Text;
        EmpDepartment: Text;
}

Without know more of your data, then I would say because the other lines does not have an employee no.

A good advise, your code is very difficult to read. You should always delete lines you no longer need. Don’t save them in code, it makes it unreadable. Without those lines it would be easy and readable. My guess it took me at least twice the time to read and understand your code, than what it would have take if the code had been CLEAN!!

AND Hungarian notation is so much the 90’ies! Why would you ever do stuff like that in VSCode?? [emoticon:ca08b2c27c2f40e993e89508acf29e0b]

Any solution to the issue ?

Should I send you the clear code !

If you want anyone to be able to help you, without spending 15-30 minutes trying to understand your code, then that would be a good idea.

Code like this would NEVER pass our code review…