Re: Help with Velocity Script

Tim_Madel1
Level 4

I am trying to use this script:

2

3

4

5

#set ($fname = ${lead.FirstName})

#if($fname.equals(""))

#else

Hello ${lead.FirstName}),

#end

Shared by Jenna Molby on here site here 4 Examples of Velocity Email Scripting in Marketo

Unfortunately it is not working for me - this is what I get in attached screenshot.

I noticed that there seemed to be an extra paran at the end of line 5 - removed it and ended up with the exact same result minus the pareb

4 REPLIES 4
Tim_Madel1
Level 4

Awesome - thanks for the help!

Sanford - thanks for simplifying things

Kenny_Elkington
Marketo Employee

You have the $ and { swapped in your image. Flip their positions and it should work.

SanfordWhiteman
Level 10 - Community Moderator

(saw that too)

SanfordWhiteman
Level 10 - Community Moderator

The code is needlessly complex.  I feel like people (not singling you out) don't understand that Velocity objects are Java wrappers, so they support the same chaining that Java does, and you don't need all kinds of intermediate variables.

#if (!$lead.FirstName.isEmpty())

Hello ${lead.FirstName}

#end