Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

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

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.")));
               

        }
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 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
    YUN ZHU 73,333 Super User 2024 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
    Inge M. Bruvik 32,748 Super User 2024 Season 1 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
    Hein Kruger 501 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans