Microflow expression for a failed parseDecimal function

1
Hello -  I have a microflow that converts a string to a decimal (parseDecimal) and stores that new value in a separate decimal attribute. I'm doing this using a $variable, and I would like to return a message if the $variable doesn't contain something that can convert - so "1.5" would convert, but "text" would not, for example. Anyone know how to write this expression in Mendix? Thanks, Mark
asked
2 answers
4

Hi Mark,

You can provide a default value for when the parse fails:

parseDecimal('3.45') returns 3.45
parseDecimal('text', 5.05) returns 5.05
parseDecimal('text', empty) returns empty

More about parseDecimal:  https://docs.mendix.com/refguide/parse-and-format-decimal-function-calls

Hope this helps.

Cheers, Jeffrey

answered
1

Just adding my bit on the difference between parseDecimal() in Nanoflows and Microflows:

In Nanoflows you can only get 8 decimal precision, while in Microflows, you can get 9. This makes a difference, e.g. when parsing geolocation/lat or longitude.

Best regards, Wouter

answered