German Salutation - Velocity Script | Community
Skip to main content
Gerard_Donnell4
Level 9
March 7, 2017
Question

German Salutation - Velocity Script

  • March 7, 2017
  • 1 reply
  • 5838 views

I am completely new to Velocity Scripting and have been tasked with setting up German Salutation to auto populate.  Can you tell me if this would work or what is wrong with it. My email will basically have a {{My.Salutation}} at the top that will pipe in the salutation based on the script token below. Thanks in advance for any help.

#if (${lead.Salutation} == "")

Sehr geehrte/r Frau/Herr ${lead.last_Name}

#elseif

(${lead.Salutation} == "Herr")

Sehr geehrter Herr ${lead.last_Name}

#elseif

(${lead.Salutation} == "Frau")

Sehr geehrte Frau ${lead.last_Name}

#elseif

(${lead.Salutation} == "Herr Dr.")

Sehr geehrter Herr Dr. ${lead.last_Name}

#elseif

(${lead.Salutation} == "Frau Dr.")

Sehr geehrte Frau Dr. ${lead.last_Name}

#elseif

(${lead.Salutation} == "Herr Prof.")

Sehr geehrter Herr Prof. ${lead.last_Name}

#elseif

(${lead.Salutation} == "Frau Prof.")

Sehr geehrte Frau Prof. ${lead.last_Name}

#elseif

(${lead.Salutation} == "Herr Prof. Dr.")

Sehr geehrter Herr Prof. Dr. ${lead.last_Name}

#elseif

(${lead.Salutation} == "Frau Prof. Dr.")

Sehr geehrte Frau Prof. Dr. ${lead.last_Name}

#end

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

1 reply

Gerard_Donnell4
Level 9
March 7, 2017

@Sanford Whiteman​ Im hoping you could help me solve this. 

Thanks,

Gerard

Casey_Grimes2
Level 10
March 7, 2017

So, just taking a cursory look at this, this script could be incredibly simplified to:

#set ($greetCheck = ${lead.Salutation})

#if ($greetCheck.contains('Herr'))

Sehr geehter $greetCheck ${lead.LastName}

#elseif ($greetCheck.contains('Frau'))

Sehr geehrte $greetCheck {lead.LastName}

#else

Sehr geehrte/r Frau/Herr ${lead.LastName}

#end

which should work just fine for you.

SanfordWhiteman
Level 10
March 7, 2017

It's not really a contains, though. It's like a startsWith\b, which needs a regex. Plus unknown Salutations aren't necessarily supposed to be output.