I have some data coming in with decimals and I was hoping to round it with velocity. For example, I have some numbers coming in as 34.36 and would like it to show 34.
Solved! Go to Solution.
Get yourself a proper number-rounder and use it:
#set( $integerFormat = $number.getNumberFormat("integer", $convert.toLocale("en_US")) )
#set( $void = $integerFormat.setRoundingMode($field.in($integerFormat.getRoundingMode()).HALF_UP) )
${integerFormat.format($number.toNumber($lead.YourField))}
(Assuming of course you meant arithmetic rounding.)
Well, it’s not actually possible to stop multiple COs from being created. So you always want to loop over the list, even if 99.9999% of the time it has only one item in it.
Like so:
#set( $integerFormat = $number.getNumberFormat("integer", $convert.toLocale("en_US")) )
#set( $void = $integerFormat.setRoundingMode($field.in($integerFormat.getRoundingMode()).HALF_UP) )
#if( !$CustomObjectList.isEmpty() )
#foreach( $object in $CustomObjectList )
${integerFormat.format($number.toNumber($object.YourField))}
#end
#end
Get yourself a proper number-rounder and use it:
#set( $integerFormat = $number.getNumberFormat("integer", $convert.toLocale("en_US")) )
#set( $void = $integerFormat.setRoundingMode($field.in($integerFormat.getRoundingMode()).HALF_UP) )
${integerFormat.format($number.toNumber($lead.YourField))}
(Assuming of course you meant arithmetic rounding.)
This is great, thank you. If you don't mind can you telling me how I would incorporate my custom object field in this? I am receiving the number through a custom object field and need my token to round the integer and display in my email. Thank you!
Well, a person can have multiple CO records. Do you want to output this single field (rounded) for each CO record?
Yes, it's just one field that I need to have rounded. We don't create multiple custom object records, just update the fields.
Well, it’s not actually possible to stop multiple COs from being created. So you always want to loop over the list, even if 99.9999% of the time it has only one item in it.
Like so:
#set( $integerFormat = $number.getNumberFormat("integer", $convert.toLocale("en_US")) )
#set( $void = $integerFormat.setRoundingMode($field.in($integerFormat.getRoundingMode()).HALF_UP) )
#if( !$CustomObjectList.isEmpty() )
#foreach( $object in $CustomObjectList )
${integerFormat.format($number.toNumber($object.YourField))}
#end
#end
Thank you SO much! Looks like it working.