Skip to main content

Notifications

Announcements

No record found.

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

        }
  • 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 74,115 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 505 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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans