Convert a string to int with Velocity | Community
Skip to main content
Franky_Ruyssch2
Level 4
Sep 9, 2019 6:53 AM UTC
Solved

Convert a string to int with Velocity

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Sep 9, 2019 7:47 AM UTC
#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
Level 10
Sep 11, 2019 3:53 AM UTC

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

Translate
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Sep 9, 2019 7:47 AM UTC
#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
Translate