velocity script newbie - lowercase first initial | Community
Skip to main content
Community Advisor
July 20, 2016
Question

velocity script newbie - lowercase first initial

  • July 20, 2016
  • 4 replies
  • 6549 views

Hi there - just learned that velocity scripting exists in Marketo! Where have I been, under a rock somewhere!? Anyway, now I just wish I knew how to use it. In the meantime, maybe someone can help point me in the right direction on how to get a lowercase first initial for my lead records?  I tried to modify an uppercase script (granted it does the whole name, but 1 thing at a time) and I couldn't even get that to work (changed 'capitalize' to 'lowercase').

Thanks all!!

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

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

there

#else

$display.lowercase($fname)

#end

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

4 replies

Frank_Breen2
Level 8
July 22, 2016

JD I think this is the code you want:

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

$display.uncapitalize($fname)

Info here. Look at this article too.

JDNelson1Community AdvisorAuthor
Community Advisor
July 24, 2016

Thanks - I'm getting "$display.uncapitalize($fname)" in my email when I test it. AmI doing something wrong?

Nicholas_Manojl
Level 8
July 24, 2016

It's actually like this:

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

<p>Hi $fname</p>

Just be mindful this actually makes the entire word lowercase.

Alternatively you could make just the first letter lower case:

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

<p>Hi $display.uncapitalize($fname)</p>

Or you could make everything uppercase first, and then just make the first letter lowercase (why?).

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

<p>Hi $display.uncapitalize($fname)</p>

JDNelson1Community AdvisorAuthor
Community Advisor
July 26, 2016

what if I just want the first letter of the first name?

i.e. "j"

Nicholas_Manojl
Level 8
July 26, 2016

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

<p>Hi $display.uncapitalize($fname)</p>

So it someone is in your database as FRANK, it will render as fRANK.

Frank_Breen2
Level 8
July 25, 2016

Also it seems like you didn't have First Name selected in the Lead Section of the Script Token, this is why you see that output:

Nicholas_Manojl
Level 8
July 26, 2016

Ah right.

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

$x.charAt(0)

Mark me correct, I want the points

JDNelson1Community AdvisorAuthor
Community Advisor
July 27, 2016

Sorry, now I'm not sure how to combine both of these; lowercase and first character only.

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

$display.uncapitalize($fname)

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

$x.charAt(0)

(did not work, obviously)

Nicholas_Manojl
Level 8
July 27, 2016

It's as simple as..

#set ($x = ${lead.FirstName.toLowerCase()})

$x.charAt(0)