Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

num2str culture settings

Posted on by 85

Hi, 
I have several API methods which are using 

num2str(num,0,2,0,0)))

as number to string conversion. It worked fine in 2009 returning proper locale settings based
on windows settings, but in D365 does it does not seem to be the case. When I currently use
it . (dot) as separator is returned. If I change 0 to 99 then , (coma) as separator is returned. 

Now the question is - from where exactly locale settings are taken from to do the conversion?
I've tried user setting and local server settings, but it didn't change the result. 

  • Verified answer
    luksz Profile Picture
    luksz 85 on at
    RE: num2str culture settings

    This is exactly what we are going to do - add additional parameter to have control over conversion.

  • Suggested answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: num2str culture settings

    Instead of using num2str directly, you can open a field in the parameter tables, add a method to the global and manage the situation

    Or you can import the value from outside instead of using constant value(1/2)

  • luksz Profile Picture
    luksz 85 on at
    RE: num2str culture settings

    We're in EU, so coma is used for our customers, at least for now. I was simply wondering if it's possible to have it more flexible if UK customer would appear one day.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: num2str culture settings

    I don't know, but I think you should just specify what you want and not trust "Auto" in integrations.

    Can we solve your business requirement by specifically telling the function what kind of format we want?

  • luksz Profile Picture
    luksz 85 on at
    RE: num2str culture settings

    Hi Nikolaos,

    User settings work fine for the GUI, but it seems that not that good for the APIs. I have Azure app running on user with DA number format (which uses , as separator), I've changed num2str so 99 are now used. API returns values with coma. If I change settings on that user to en-US still coma is returned as separator. What am I missing?

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: num2str culture settings

    Hi,

    by looking at the documentation, I don't think that 0 is a supported value for decimal separator. I'm not sure what settings the Auto option is using, I would assume it uses the settings of the current user. Just like the number formatting on all D365 forms uses the user's settings to format the values.

    You can provide 1, 2 or 99 as the decimal separator option, but 0 is not one of the supported values. 99 means Auto, 1 means Dot and 2 means Comma.

    Thousand separator has a bit more options, but you can find them all in AOT under System documentation -> Base enums -> ThousandSeparator (the decimal separator is using DecimalSeparator enum).

    docs.microsoft.com/.../xpp-conversion-run-time-functions

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,336 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans