SOLVED

Velocity Script Help

Go to solution
juleary324
Level 2

Hi - 

 

I'm currently working on a nurture targeting MQLs who have stopped responding to our BDRs. The emails will come from their BDR, but we are having a hard time filling out the From name and the signature. We have an sfdc custom object that accurately pulls in the contact's BDR email address (so reply-to and sender email is accurate) but we do not have a reliable field to pull in the contact's BDR Owner's name (From Name).

 

Does anyone have a velocity script to pull in the first and last name from the email address field? The structure of our BDRs emails is as follows: john.smith@company.com 

So in an ideal state the velocity script would pull in the first and last name like: John Smith

 

Thanks!

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

What do you do if someone uses their middle name or initial? What about hyphenated first or last names?

 

In other words, is it possible with 100% accuracy to determine the correct values and correct case of the person’s First and Last from their Email?

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

@juleary324 please update based on my questions.

 

I don’t want to contribute code that doesn’t cover these edge cases.  Do you really mean it’s as easy as “split on the period, take the first and final item from the resulting array and make them First and Last respectively, and change the first letter of each to uppercase”?

SanfordWhiteman
Level 10 - Community Moderator

What do you do if someone uses their middle name or initial? What about hyphenated first or last names?

 

In other words, is it possible with 100% accuracy to determine the correct values and correct case of the person’s First and Last from their Email?

juleary324
Level 2

Yes this is a small subset and with 100% accuracy all of the emails are transferable to the correct First and Last name form the email.

SanfordWhiteman
Level 10 - Community Moderator

Replacing $lead.YourEmailField with whatever the Velocity object/field name is for your BDR email:

#set( $emailField = $lead.YourEmailField )
#set( $lhs = $emailField.substring(0,$emailField.lastIndexOf("@")) )
#set( $lhsParts = $lhs.split("\.") )
#set( $impliedFirstName = $lhsParts[0] )
#set( $impliedLastName = $lhsParts[$math.sub($lhsParts.size(),1)] )
#set( $displayName = $display.capitalize($impliedFirstName.toLowerCase()) + " " + $display.capitalize($impliedLastName.toLowerCase()) )
${displayName}