Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Custom number format please help

Posted on by Microsoft Employee

Hello, i'm trying to create a template for my company and I got stuck on one thing:

My company uses the following number format example: 123 987 456.00. The thing i want to make is this: 

In c/al code -BodyLineText[6]:= STRSUBSTNO('%1', FORMAT(XXXXXXXXXXXXXXX ,0,'### ### ##.00')); I tried looking on how to make this work, but with no luck, the default formats like 

  • <Sign><Integer Thousand><Decimals> is Format 0

  • <Sign><Integer><Decimals> is Format 1

  • <Sign><Integer><Decimals><1000Character,.> is Format 2

  • <Integer Thousand><Decimals><Sign,1> is Format 3

  • <Integer><Decimals><Sign,1> is Format 4

is not good enough for my company. The if I replace the '### ### ##.00' with the formats mentioned above example: BodyLineText[6]:= STRSUBSTNO('%1', FORMAT(XXXXXXXXXXXXXXX ,0,0)); it works perfectly, but the format is not what i need. I know that i can do it much simplier in visual studio if i change the BodyLineText from text into decimal, but thats not what i want to make. Is the format what i want to make even possible to do? Maybe someone could help me.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Custom number format please help

    Thank you Binesh Singh Rajput and Christopher007

  • Verified answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Custom number format please help

    Hello,

    Christopher007 solution is working, 

    //you have to call your Decimal Variable with FORMAT so format inserted comma after every 3 digits

    DecimalVariable := 123456789.12;
    MESSAGE('%1',Replace(FORMAT(DecimalVariable),',',' '));

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Custom number format please help

    Yes my goal is to make spaces as a thousand separator.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Custom number format please help

    Hi,

    I am not sure how you want to make it look like at the end. Is it the spaces between the numbers?

    Maybe this custom function will help you.

    Replace(String : Text;FindWhat : Text;ReplaceWith : Text) NewString : Text
    WHILE STRPOS(String,FindWhat) > 0 DO BEGIN
      String := DELSTR(String,STRPOS(String,FindWhat)) + ReplaceWith + COPYSTR(String,STRPOS(String,FindWhat) + STRLEN(FindWhat));
    END;
    NewString := String;
    Var                       Name                   DataType            Subtype              Length
    No                        String                   Text                                                 
    No                        FindWhat            Text                                                 

    No                        ReplaceWith      Text

    Then you can replace the spaces in the text.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans