Skip to main content
Level 2
Jun 11, 2024 6:21 PM UTC
Solved

Rounding numbers with velocity

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. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Jun 12, 2024 1:00 AM UTC

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.)

6 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Jun 12, 2024 1:00 AM UTC

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.)

Translate
KainelsonAuthor
Level 2
Jun 12, 2024 5:40 PM UTC

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!

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Jun 12, 2024 6:55 PM UTC

Well, a person can have multiple CO records. Do you want to output this single field (rounded) for each CO record?

Translate