I have a few fields formatted as number with either 1 or 2 decimal places. I am using these values in a concatenated string in another field, and I want to use the formatted number in this calculation. Using either field.value or field.valueAsString just gets the value as entered i.e. '412' instead of '412.0'.
Is there an easy way to directly get the value as it is formatted, or do I need to replicate the formatting when I am concatenating the string?
There's no easy way in general. The built-in formatting routine for numbers uses the util.printf method, so for the example you gave it's easy to replicate.
Thanks, I figured that was the case. I might end up using a custom formatting solution for the display field as well, just so I can be sure that both fields use exactly the same code. I'm sure sometime in the future, they could have me change something, and I'd likely forget that it uses different code to format the printable field.