SOLVED

Convert a string to int with Velocity

Go to solution
Franky_Ruyssch2
Level 4

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}
Franky Ruysschaert
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Convert a string to int with Velocity

#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

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Convert a string to int with Velocity

#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 - Community Moderator

Re: Convert a string to int with Velocity

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