web
You’re offline. This is a read only version of the page.
close
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

BC - coding problem

(0) ShareShare
ReportReport
Posted on by 55

Hi,

I have a req to create a couple new fields on the "Bank Account List" page. 
one field is Selected Payments. For this , i used a Calcformula to tally all the payments made using each bank account. 

This works, here's my code 

tableextension 50125 BankAccountTableExtension extends "Bank Account"
{
    fields

    {

        field(50001; "Selected Payments"; Decimal)

        {

            Caption = 'Selected Payments';
            AutoFormatType = 1;
            CalcFormula = Sum("Gen. Journal Line".Amount WHERE("Bal. Account No." = FIELD("No.")));


            Editable = false;
            FieldClass = FlowField;

        }

    }
}
I have to create another field called "Projected Balance" 
This would be the Bank Account balance - Selected Payments
However, i can't seem to find anything online that would help with a "minus" function
This is what i have so far - it may be very wrong - but this is the first set of code i've written using AL.
Any assistance would be greatly appreciated.
tableextension 50126 ProjectedBalance extends "Bank Account"
{
    fields
    {
        field(50126; "Projected Balance"; Decimal)
        {
            Caption = 'Projected Balance';


        }
    }




    procedure GetProjectedBalance(var "Selected Payments": Decimal; var "Projected Balance": Decimal)
    begin
        CalcFields(Balance);
        "Selected Payments" := "Selected Payments";
        "Projected Balance" := Balance - "Selected Payments";
    end;


}
I have the same question (0)
  • Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    I doubt below line

    procedure GetProjectedBalance(var "Selected Payments": Decimal; var "Projected Balance": Decimal)

       begin

           CalcFields(Balance);

           "Selected Payments" := "Selected Payments";

           "Projected Balance" := Balance - "Selected Payments";

       end;

    make some correction

    procedure GetProjectedBalance(var "Selected Payments": Decimal; var "Projected Balance": Decimal)

       begin

           CalcFields(Balance);

           "Selected Payments2" := "Selected Payments";

           "Projected Balance" := Balance - "Selected Payments2";

       end;

  • Rajiv Sewsarran Profile Picture
    55 on at

    Hi Nitin,

    Thanks for getting back to me.

    I've tried this but it still returns 0.00 as the Projected balance

  • Suggested answer
    Giambattista Malvasi  Profile Picture
    195 on at

    You can Try:

        procedure GetProjectedBalance() "Projected Balance": Decimal
        begin
            CalcFields(Rec.Balance);
            CalcFields(Rec."Selected Payments");
            "Projected Balance" := Rec.Balance - Rec."Selected Payments";
        end;
  • Rajiv Sewsarran Profile Picture
    55 on at

    Hi, thanks for replying.

    I'm getting a new error now

    error AL0132: 'Record "Bank Account"' does not contain a definition for 'Selected Pmts'

    I uninstalled the extension and created a new one from scratch

    The field appears on the Bank Account list and is calculating as it should

    But when i try to do the new Tableextension for the Projected Balance i get this error

  • Giambattista Malvasi  Profile Picture
    195 on at

    Were is the error?

  • Rajiv Sewsarran Profile Picture
    55 on at

    its on the tableextension

    error AL0132: 'Record "Bank Account"' does not contain a definition for 'Selected Pmts'

  • Giambattista Malvasi  Profile Picture
    195 on at

    Field name is correct? Field Name is "Selected Payments" or "Selected Pmts"?

  • Rajiv Sewsarran Profile Picture
    55 on at

    yup field name is correct i created a new one called Selected Pmts

  • Giambattista Malvasi  Profile Picture
    195 on at

    you have 2 choose to choose the same table?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans