SOLVED

Re: Velocity Script to extract first name from full name

Go to solution
Broderick_Klem1
Level 4

Velocity Script to extract first name from full name

In Marketo we have a name field that stores a full name (always in the format of "firstname lastname"). I'm sure I can use a custom token script to trim that string to just first name, but I'm not sure how to do it. Does anyone have the script already done that allows for this? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script to extract first name from full name

$lead.fullName.split(" ")[0]

You have to figure out what to do when someone has a compound first or last name (and you won't know which it is).

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script to extract first name from full name

$lead.fullName.split(" ")[0]

You have to figure out what to do when someone has a compound first or last name (and you won't know which it is).

Broderick_Klem1
Level 4

Re: Velocity Script to extract first name from full name

Thanks!

Broderick_Klem1
Level 4

Re: Velocity Script to extract first name from full name

Will this just delete everything after the first space? So for example, if their name is Ulrich von Liechtenstein, will this script just return "Ulrich"? That is what we are wanting.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script to extract first name from full name

Will this just delete everything after the first space?

I wouldn't put it that way exactly: it splits the string into substrings, then returns the first substring (nothing is deleted per se, it just isn't referenced).

So yes, if someone has a 3-part or 4-part full name like "Ulrich von Liechtenstein" it will always return the 1st part, "Ulrich".

In turn this means "Theresa Ann Clark" will return "Theresa" even if she goes by "Theresa Ann"... that's the cost of not actually knowing where it breaks in real life!