Using decimal values in emailtemplates

After upgrading MxModelReflection to the latest version, it is possible to use decimal values in emailtemplates. The value 500 is stored as 500.00000000 because of the digit precision and therefore also replaced in the emailtemplate as 500.00000000. But..I want to see 500.00 because they are doekoes. I have seen this tread about using string values instead of decimal but this seems redundant to me. Is it possible to set the number of digits when using decimal values in e-mailtemplates?
2 answers

The current version in the appstore does not have that ability. However this is something I did have but just never got to publish back to the appstore.

There is a version ready for publishing to the appstore (it just has to go through the approval process). The token logic is part of the appstore module MxModelReflection, the new version 5.5 (requires Mx 5.18 or higher) allows you to specify a display pattern per token.

That Display pattern used a Java Formatter to alter the way the attribute is presented rather than dumping all values to a string as is done now. By default this pattern will remain empty and it will follow the current behavior.

For fields such as Decimals or your doekoes it uses the DecimalFormatter to print the decimals. So you'd probably want to use a pattern such as:     € #,##0.00

For completeness dates are formatted using SimpleDateFormat, all other attributes are formatted using Formatter

I'd expect this new version of Model Reflection(5.5) to be published later this week.


If you use string attributes for your entity that is being passed to the template then you can fill that attribute with a formatDecimal() function here to get your desired output.