Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

System.Format() for leading zeroes

Posted on by 29

Hi everyone!

I'm trying to write a function that will take values from a table and write them to a plain text file.

In order to make the text easier to read, I'm trying to get the values in some of the columns to all be the same length. I want to achieve this by using leading zeroes.

So, let's say I want all the values to be five characters in length. If the value in the column was 99, it would be written as 00099. If it was 999, it would be written as 00999.

I understand the function System.Format() can help me achieve this, but unfortunately I haven't been able to figure out how. Does anyone know what value I have to give in the Format parameter in order to achieve this kind of result? Or maybe an alternate solution altogether?

Thanks for your time!

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: System.Format() for leading zeroes

    Hi, here are two great examples that hopefully give you some hints.

    (99+) how to format quantity - Dynamics 365 Business Central Forum Community Forum

    Thanks

    ZHU

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans