Convert a string to int with Velocity | Community
Skip to main content
Franky_Ruyssch2
Level 4
September 9, 2019
Solved

Convert a string to int with Velocity

  • September 9, 2019
  • 2 replies
  • 7866 views

I need to convert a lead field, which holds a string to a integer with velocity scripting.

Does somebody has a solution for this?

I have tried the following, but I receive an error

#set( $tmp = 0 )
$tmp.parseInt( ${lead.PostalCode} )
${tmp}
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
#set( $anInteger = $convert.toInteger( $aString ) )‍‍

  • don't confuse "int" and "Integer", they're two different datatypes
  • use simple notation ($reference), not formal (${reference}) unless you're outputting

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
September 9, 2019
#set( $anInteger = $convert.toInteger( $aString ) )‍‍

  • don't confuse "int" and "Integer", they're two different datatypes
  • use simple notation ($reference), not formal (${reference}) unless you're outputting
SanfordWhiteman
Level 10
September 11, 2019

@Franky please return to the thread and mark my answer as Correct.