AnsweredAssumed Answered

Spript Token Outputing Velocity Code Instead of Expected Text

Question asked by Marissa Bobitt-Gonzales on Jan 4, 2019
Latest reply on Jan 4, 2019 by Sanford Whiteman

Hi All,

I'm a brand new Velocity developer (i.e, I was volunteered) and have come across my first hiccup. I first want to thank Sanford Whiteman for his fantastic blog posts and replies. I ended up Frankenstein-ing this bit of code from a few of his posts. While it works for actual names it's failing to output the fallback default. Instead I'm getting "$name.substring(0,1).toUpperCase()$name.substring(1).toLowerCase()".

 

#set($name = $lead.FirstName)
#if( $lead.FirstName.isEmpty() )
  Friend
#else
  $name.substring(0,1).toUpperCase()$name.substring(1).toLowerCase()##
#end

All names are uppercase in the db. This code is make sure the first character stays capitalized and the rest is lowercase.

 

Names pass through just fine which is 99.5% of our lists but that last .5% makes me itch. Other Info; I'm testing this with send sample and (thankfully) haven't seen anything in the wild but I expect it to work just like the oob {{lead.FirstName:defualt=Friend}} token.

 

Thanks in advanced for any suggestions or solutions!

Outcomes