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

Show only the last 4 digits of a field - AL Code

(0) ShareShare
ReportReport
Posted on by

I have a flow field that I want to show the account number for the bank account selected in a payment journal. What I would like to do is actually just show the last 4 digits of the field. Is there a way to do that within my AL code?

 field(50103; "AccountNo"; text[30]){
             FieldClass = FlowField;
            Editable = false;
            CalcFormula = lookup("Bank Account"."Bank Account No."
                where("No." = field("Bal. Account No.")));
               

        }
I have the same question (0)
  • Hein Kruger Profile Picture
    666 on at

    Hi,

    The Calcformula doesnt allow for functions like "Trim" to work inside or outside the Lookup function.

    I would suggest to create a new field Bank Account called "Last Digits". Let this field populate on the Onvalidate Trigger of the Account No.

    Let the lookup look to the new field created.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,165 Moderator on at

    You have the extended data type property that you can use to mask a field:

    learn.microsoft.com/.../devenv-extendeddatatype-property

  • Suggested answer
    YUN ZHU Profile Picture
    99,055 Super User 2026 Season 1 on at

    Hi, You can't do it with Flowfield, you need to add another field.

    Then use the following two methods should be able to get the last four digits.

    Text.CopyStr(Text, Integer [, Integer]) Method

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-copystr-method

    Text.MaxStrLen(Variant) Method

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-maxstrlen-variant-method

    Hope this can give you some hints.

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,794 Moderator on at

    Hi,

    Can you try this instead of Flow field?

    trigger OnAfterGetRecord()

       var

           BankAccount: Record "Bank Account";

       begin

           lastDigit := '';

           if BankAccount.get(<youraccountno.>) then

               lastDigit := CopyStr(BankAccount."Bank Account No.", 1, 4);

       end;

       var

           lastDigit: Code[4];

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans