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...
Answered

Job List Page. Sum of 2 Fields (AL Code)

(0) ShareShare
ReportReport
Posted on by 190

Dear Experts

Am really new to this BC and coding, really using this forum and online platform for my learning.  pls kindly request all for you kind help in my issues and correcting it in the correct way .

Right now am trying to How we can bring the Total of Actual Total cost  and Total of Billable Price (from Jobs Planning lines -Job Task table (1001)) on JOB List page. Actually Total can see also at right side from Job Cost Factbox (1030, CardPart) also

jobpost.JPG

am trying like this... pls correct me to get the desired result in attached code

 pageextension 60017 JOBPageExtension50000_50951 extends "Job List"
 {
     layout
     {
     addafter("No.")
     {

    field("Actual Total Cost"; Rec."Actual Total Cost")
    {
                ApplicationArea = All;
                Width = 14;
                Caption = 'Acutal Total Cost';
                Editable = false;

     }

            field ("Billable Total Price";Rec."Billable Total Price")
            {
                ApplicationArea = All;
                Width = 14;
                Editable = false;
            }
        }
        
    }           trigger OnafterGetRecord()
                 var
                    JobSum : Record "Job Task";
                    JobTotal : Record "Job Ledger Entry";
                    TotalCost :  Decimal;
                    TotalBill   : Decimal;

                begin

                    JobSum.SetRange("Job No.");
                    JobTotal.SetRange("Job No.");
                    JobSum.CalcSums(Jobsum.Billable Total Price);
                    JobSum.CalcSums(Jobsum.Actual Total Cost);


                    end;
                    var

                        Jobsum  Decimal;
    }

    
}

  • Suggested answer
    Nitin Verma Profile Picture
    21,394 Moderator on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Good to know, its working.. thanks.

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Thanks Alok and Nithin,

    i verified the Answer also..

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hello Nithin,

    thankyou soo much...at last got the output as expected

    added one more line in billable amount

    JobtotalBill.SetRange("Line Type", JobtotalBill."Line Type"::Billable);

    so its works fine..thanks alot...

  • Suggested answer
    Nitin Verma Profile Picture
    21,394 Moderator on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hi,

    you have to change the field correctly in our logic where actually its calculating the values for Billable and actual. please check from Job ledger entry and Planning line table.

    Thanks.

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hello Nithin,

    thankyou Soo much for the update. last when i modified the code as u said, it  shows the warning as implicit function (future releases will cause the issue like that)

    Right now i modified as per the code.

    Now all the values are came. but some of jobs are coming with wrong value and some of are correct. I don't know from where those values are picking where the incorrect are coming.

    1jotpt.JPG

  • Suggested answer
    Nitin Verma Profile Picture
    21,394 Moderator on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hi,

    You are not following the same code, what I sent you before, please change your code as per yellow marked below.

    pageextension 60017 JOBExtension50000_50951 extends "Job List"

    {

       layout

       {

           addafter("No.")

           {

               field("No. Series08206"; Rec."No. Series")

               {

                   ApplicationArea = All;

                   Width = 8;

                   Caption = 'No. Series';

               }

               field("Starting Date72908"; Rec."Starting Date")

               {

                   ApplicationArea = All;

                   Width = 10;

                   Caption = 'Starting Date';

               }

               field("Ending Date60581"; Rec."Ending Date")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Ending Date';

               }

               field("Project Cost"; Rec."Project Cost")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Project Revenue';

               }

               field("Project Expense"; Rec."Project Expense")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Project Expense';

               }

               field("Creation Date71912"; Rec."Creation Date")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Creation Date';

               }

               field("Actual Total Cost";ActualTotalCost)

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Acutal Total Cost';

                   Editable = false;

               }

               field("Billable Total Price"; BillableTotal)

               {

                   ApplicationArea = All;

                   Width = 14;

                   Editable = false;

               }

           }

       }

       trigger OnafterGetRecord()

       var

           JobSum: Record "Job Task";

           JobTotal: Record "Job Ledger Entry";

           JobtotalBill: Record "Job Planning Line";

           LineCount: Integer;

       begin

           LineCount := 0;

           JobTotal.Reset();

           JobTotal.SetRange("Entry Type", JobTotal."Entry Type"::Usage);

           JobTotal.SetRange("Job No.", Rec."No.");

           JobTotal.CalcSums("Total Cost (LCY)");

           ActualTotalCost := JobTotal."Total Cost (LCY)";

           JobtotalBill.Reset();

           JobtotalBill.SetRange("Job No.", Rec."No.");

           JobtotalBill.calcsums("Line Amount (LCY)");

           BillableTotal := JobtotalBill."Line Amount (LCY)";

           // if JobTotal.FindFirst() then

           //     repeat

           //         LineCount += 1;

           //         ActualTotalCost += JobTotal."Unit Cost (LCY)";

           //     Until JobTotal.Next() = 0;

           // End;

           // if JobtotalBill.FindFirst() then

           //     repeat

           //         LineCount += 1;

           //         BillableTotal += JobtotalBill."Unit Price";

           //     Until jobTotalBill.Next() = 0;

       end;

       var

           ActualTotalCost: Decimal;

           BillableTotal: Decimal;

    }

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Dear All,

    Still Not get the Desired Output.

    any help is highly appreciated.

    Thanks

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hi Nithin

    i run the same code like this but for my values are not coming over there. and compile and publish without any error also.

    1524.noval.JPG

    pageextension 60017 JOBExtension50000_50951 extends "Job List"
    {
        layout
        {
            addafter("No.")
            {
                field("No. Series08206"; Rec."No. Series")
                {
                    ApplicationArea = All;
                    Width = 8;
                    Caption = 'No. Series';
                }
                field("Starting Date72908"; Rec."Starting Date")
                {
                    ApplicationArea = All;
                    Width = 10;
                    Caption = 'Starting Date';
                }
                field("Ending Date60581"; Rec."Ending Date")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Ending Date';
                }
                field("Project Cost"; Rec."Project Cost")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Project Revenue';
                }
                field("Project Expense"; Rec."Project Expense")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Project Expense';
                }
                field("Creation Date71912"; Rec."Creation Date")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Creation Date';
                }
                field("Actual Total Cost"; Rec."Actual Total Cost")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Acutal Total Cost';
                    Editable = false;
                }
                field("Billable Total Price"; Rec."Billable Total Price")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Editable = false;
                }
            }
        }
        trigger OnafterGetRecord()
    
        var
    
            JobSum: Record "Job Task";
    
            JobTotal: Record "Job Ledger Entry";
    
            JobtotalBill: Record "Job Planning Line";
    
            LineCount: Integer;
    
        begin
    
            LineCount := 0;
    
            JobTotal.Reset();
    
            JobTotal.SetRange("Entry Type", JobTotal."Entry Type"::Usage);
    
            JobTotal.SetRange("Job No.", Rec."No.");
    
            JobTotal.CalcSums("Total Cost (LCY)");
    
            ActualTotalCost := JobTotal."Total Cost (LCY)";
    
            JobtotalBill.Reset();
    
            JobtotalBill.SetRange("Job No.", Rec."No.");
    
            JobtotalBill.calcsums("Line Amount (LCY)");
    
            BillableTotal := JobtotalBill."Line Amount (LCY)";
    
            // if JobTotal.FindFirst() then
    
            //     repeat
    
            //         LineCount  = 1;
    
            //         ActualTotalCost  = JobTotal."Unit Cost (LCY)";
    
            //     Until JobTotal.Next() = 0;
    
            // End;
    
            // if JobtotalBill.FindFirst() then
    
            //     repeat
    
            //         LineCount  = 1;
    
            //         BillableTotal  = JobtotalBill."Unit Price";
    
            //     Until jobTotalBill.Next() = 0;
    
        end;
    
        var
    
            ActualTotalCost: Decimal;
    
            BillableTotal: Decimal;
    
    }
    

  • Suggested answer
    Nitin Verma Profile Picture
    21,394 Moderator on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hi,

    Please take the last changes and find the image.

    pastedimage1653483561133v1.png

    pageextension 60017 "JOBExtension50000_50951" extends "Job List"

    {

       layout

       {

           addafter("No.")

           {

               field("No. Series08206"; Rec."No. Series")

               {

                   ApplicationArea = All;

                   Width = 8;

                   Caption = 'No. Series';

               }

               field("Starting Date72908"; Rec."Starting Date")

               {

                   ApplicationArea = All;

                   Width = 10;

                   Caption = 'Starting Date';

               }

               field("Ending Date60581"; Rec."Ending Date")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Ending Date';

               }

               field("Project Cost"; Rec."Project Cost")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Project Revenue';

               }

               field("Project Expense"; Rec."Project Expense")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Project Expense';

               }

               field("Creation Date71912"; Rec."Creation Date")

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Creation Date';

               }

               field("Actual Total Cost"; ActualTotalCost)

               {

                   ApplicationArea = All;

                   Width = 14;

                   Caption = 'Acutal Total Cost';

                   Editable = false;

               }

               field("Billable Total Price"; BillableTotal)

               {

                   ApplicationArea = All;

                   Width = 14;

                   Editable = false;

               }

           }

       }

       trigger OnafterGetRecord()

       var

           JobSum: Record "Job Task";

           JobTotal: Record "Job Ledger Entry";

           JobtotalBill: Record "Job Planning Line";

           LineCount: Integer;

       begin

           LineCount := 0;

           JobTotal.Reset();

           JobTotal.SetRange("Entry Type", JobTotal."Entry Type"::Usage);

           JobTotal.SetRange("Job No.", Rec."No.");

           JobTotal.CalcSums("Total Cost (LCY)");

           ActualTotalCost := JobTotal."Total Cost (LCY)";

           JobtotalBill.Reset();

           JobtotalBill.SetRange("Job No.", Rec."No.");

           JobtotalBill.calcsums("Line Amount (LCY)");

           BillableTotal := JobtotalBill."Line Amount (LCY)";

           // if JobTotal.FindFirst() then

           //     repeat

           //         LineCount += 1;

           //         ActualTotalCost += JobTotal."Unit Cost (LCY)";

           //     Until JobTotal.Next() = 0;

           // End;

           // if JobtotalBill.FindFirst() then

           //     repeat

           //         LineCount += 1;

           //         BillableTotal += JobtotalBill."Unit Price";

           //     Until jobTotalBill.Next() = 0;

       end;

       var

           ActualTotalCost: Decimal;

           BillableTotal: Decimal;

    }

  • LearnBC Profile Picture
    190 on at
    RE: Job List Page. Sum of 2 Fields (AL Code)

    Hello Dear..

    i really appreciate your kind help and time for solving this issue.

    variable also i changed before itself. kindly check with my last code. Still Fields are coming with 0 values. as before.

    pageextension 60017 JOBExtension50000_50951 extends "Job List"
    {
        layout
        {
            addafter("No.")
            {
                field("No. Series08206"; Rec."No. Series")
                {
                    ApplicationArea = All;
                    Width = 8;
                    Caption = 'No. Series';
                }
                field("Starting Date72908"; Rec."Starting Date")
                {
                    ApplicationArea = All;
                    Width = 10;
                    Caption = 'Starting Date';
                }
                field("Ending Date60581"; Rec."Ending Date")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Ending Date';
                }
                field("Project Cost"; Rec."Project Cost")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Project Revenue';
                }
                field("Project Expense"; Rec."Project Expense")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Project Expense';
                }
                field("Creation Date71912"; Rec."Creation Date")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Creation Date';
                }
                field("Actual Total Cost"; Rec."Actual Total Cost")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Caption = 'Acutal Total Cost';
                    Editable = false;
                }
                field("Billable Total Price"; Rec."Billable Total Price")
                {
                    ApplicationArea = All;
                    Width = 14;
                    Editable = false;
                }
            }
        }
        trigger OnafterGetRecord()
    
        var
    
            JobSum: Record "Job Task";
    
            JobTotal: Record "Job Ledger Entry";
    
            JobtotalBill: Record "Job Planning Line";
    
            LineCount: Integer;
    
        begin
    
            BillableTotal := 0;
    
            LineCount := 0;
    
            JobTotal.Reset();
    
            JobTotal.SetRange("Entry Type", JobTotal."Entry Type"::Usage);
    
            JobTotal.SetRange("Job No.", Rec."No.");
    
            JobTotal.CalcSums("Total Cost (LCY)");
    
            ActualTotalCost := JobTotal."Total Cost (LCY)";
    
            JobtotalBill.Reset();
    
            JobtotalBill.SetRange("Job No.", Rec."No.");
    
            JobtotalBill.SetAutoCalcFields("Invoiced Amount (LCY)");
    
            if JobtotalBill.FindSet() then
                repeat
    
                    BillableTotal  = JobtotalBill."Invoiced Amount (LCY)";
    
                until JobtotalBill.Next() = 0;
    
        end;
    
        var
            ActualTotalCost: Decimal;
    
            BillableTotal: Decimal;
    
    }
    
    
    
    
    
    
    

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,910 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,782 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans