Help with Velocity Script | Community
Skip to main content
Level 3
August 8, 2016
Question

Help with Velocity Script

  • August 8, 2016
  • 3 replies
  • 2004 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

SanfordWhiteman
Level 10
August 8, 2016

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
Adobe Employee
Adobe Employee
August 8, 2016

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

SanfordWhiteman
Level 10
August 8, 2016

(saw that too)

Level 3
August 9, 2016

Awesome - thanks for the help!

Sanford - thanks for simplifying things