parseDecimal not working as expected.

0
Morning all!   I'm running into a problem with the parseDecimal function in Mx version 9.24.1. I see that the amount given back is wrong by several decimal places. To test this I used the Mx documentation example (found here https://docs.mendix.com/refguide/parse-and-format-decimal-function-calls/).   According to this documentation: I ran this in a test flow:   As shown in the popup message, the value given back is not the same as the value shown in the documentation. This is also the value shown when I debug this:   Has anyone else run into this issue or does anyone have advice on this?     EDIT: Just on language settings – We have a dutch app but receive this string with international decimal formatting (3,241.98).   Changing the parse format isn't allowed – for example #.###,## will throw an error, as does changing the format of the given string, for example 3.241,98.
asked
4 answers
2

If it is purely a string you are getting I would parse it differently. Go find first the comma and dots inside the string. Depending on the amount of comma's and dots and if the last character is a dot or comma you know what format it is. And based on that result remove either all the comma's or all the dots and do a replcase of the other one (so a dot becomes a comma and a comma becomes a dot. Then you could parse it normally. So for instance the string is 3.456.789,12 has two dots and one comma as last you remove the dots and change the comma so it becomes 3456789.12 which you can parse normally to a decimal.
Now it becomes more tricky if you have a value like 3.45,6789. The count is equal but the last one is a comma. So again remove the dots in the string and replace the comma for a dot so you get 345.6789 which again can be parsed to a normal decimal.

Regards,
Ronald

answered
2

This is down to the language locale settings in the application. Different languages using different formats for decimals.

I wrote a marketplace module to get around this and give you more flexibility in parsing. This allows you to set the grouping and decimal separators independently of your locale.

https://marketplace.mendix.com/link/component/119981

I hope this helps.

 

answered
1

Hello Belle,

 

This might be related to Language specific settings. For example UK and US use the comma and dot exactly opposite.

answered
1

Have you checked on the page itself? 

answered