Rounding numbers with velocity | Community
Skip to main content
New Participant
June 11, 2024
Solved

Rounding numbers with velocity

  • June 11, 2024
  • 1 reply
  • 2612 views

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.
Best answer by SanfordWhiteman

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

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 12, 2024

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

KainelsonAuthor
New Participant
June 12, 2024

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!

SanfordWhiteman
New Participant
June 12, 2024

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