Help with Velocity Script

Tim_Madel1
Level 4

Help with Velocity Script

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
SanfordWhiteman
Level 10 - Community Moderator

Re: Help with Velocity Script

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

Kenny_Elkington
Marketo Employee

Re: Help with Velocity Script

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Help with Velocity Script

(saw that too)

Tim_Madel1
Level 4

Re: Help with Velocity Script

Awesome - thanks for the help!

Sanford - thanks for simplifying things