web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Suggested answer
    Nitin Verma Profile Picture
    21,666 Moderator on at
    RE: Show only the last 4 digits of a field - AL Code

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

  • Suggested answer
    YUN ZHU Profile Picture
    92,429 Super User 2025 Season 2 on at
    RE: Show only the last 4 digits of a field - AL Code

    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
    Inge M. Bruvik Profile Picture
    1,037 Moderator on at
    RE: Show only the last 4 digits of a field - AL Code

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

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

  • Hein Kruger Profile Picture
    629 on at
    RE: Show only the last 4 digits of a field - AL Code

    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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,119

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,902

#3
Sumit Singh Profile Picture

Sumit Singh 3,021

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans