Velocity Script to convert value into currency

Bharti19
Level 1

Velocity Script to convert value into currency

I have a field called Prev YTD Transaction Volume which has numerical data in the format 12387646. I am trying to write a velocity script to present this data in a currency format $12,387,646.00. The token for my field is {{lead.Prev_YTD_Transaction_Volume__c}}

What would be the best way to write the script. I current have the script as below but the value returned is incorrect.

 

#set($total = ${lead.Prev_YTD_Transaction_Volume__c})
#set ($total = $number.currency($total))
${total}
1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script to convert value into currency

You’ll need to explain exactly what you mean by “incorrect”.


The code is basically fine if that’s the real field name and it’s an Integer. You don’t need the curly braces within the #set directive, though.

#set( $total = $lead.Prev_YTD_Transaction_Volume__c )
#set( $total = $number.currency($total) )
${total}