Boris
07/01/2025, 8:20 AMCeligo AI
07/01/2025, 8:21 AMAI generated answer (using internal Slack threads):In FreeMarker, you can convert a string to a number using the
?number
built-in function. However, if the string contains non-numeric characters such as a currency symbol, you will need to remove these before attempting the conversion.
In the context of your question, if record.total
is a string that represents a number, you can convert it to a number using record.total?number
.
However, if record.total
contains non-numeric characters, you will need to remove these first. For example, if record.total
is a string that represents a currency amount (e.g., "$100.00"), you can remove the currency symbol using the ?replace
built-in function before converting to a number:
freemarker
<#assign total = record.total?replace("[^\\d.]", "", "r")?number>
This line of code replaces all non-digit and non-dot characters in record.total
with an empty string, effectively removing them. The result is then converted to a number using ?number
.
Please note that this approach assumes that record.total
is a string that represents a valid number once non-numeric characters are removed. If record.total
is not a string or does not represent a valid number, you will need to handle these cases separately.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
07/01/2025, 8:21 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.795911252
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.791835248
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.791538298
Celigo AI
07/01/2025, 8:21 AM