Microflow expression for a failed parseDecimal function

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
2 answers

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


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