Velocity Scripting Token help | Community
Skip to main content
New Participant
August 15, 2018
Solved

Velocity Scripting Token help

  • August 15, 2018
  • 3 replies
  • 3982 views

What am I doing wrong!?

#if ($lead.FirstName.startsWith("First") )

#set ($name = "Hello")

#else

#set($name = "Hello $display.capitalize($lead.FirstName.toLowerCase())")

#end

$name

What I am trying to do... Leads can have the name "First Name 123". I want to change that to just Hello and then otherwise normalize the names (ERIN --> Erin). I can't seem to be able to figure it out!

Any help would be amazing. I am new to coding to be gentle. haha

Thank you!

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

In this particular case you should use ${formal.notation} inside the output (you should only use formal in output).

#set($name = "Hello ${display.capitalize($lead.FirstName.toLowerCase())}")

What output are you seeing?  The code looks otherwise syntactically correct. (Though I wouldn't use "name" as the variable name but rather "greeting," lest it be confusing.)

3 replies

Neil_Robertson6
New Participant
August 16, 2018

as a side note - I'm really hoping that Velocity gets replaced at some stage Marketo - it is really good but not all packages are available and with newer tech now available it will be good to get this replaced with something more robust

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 15, 2018

In this particular case you should use ${formal.notation} inside the output (you should only use formal in output).

#set($name = "Hello ${display.capitalize($lead.FirstName.toLowerCase())}")

What output are you seeing?  The code looks otherwise syntactically correct. (Though I wouldn't use "name" as the variable name but rather "greeting," lest it be confusing.)

ErinCa12Author
New Participant
August 15, 2018

Thanks Sanford!

ErinCa12Author
New Participant
August 15, 2018

Forgot to mention that FirstName is checked on the right hand side.