How can manage 'Mrs.' or 'Madame' values in my script? | Community
Skip to main content
Level 2
February 19, 2019
Question

How can manage 'Mrs.' or 'Madame' values in my script?

  • February 19, 2019
  • 2 replies
  • 1925 views

Hi Everyone...

I have the current script below but Id' like to add 'Madame' and 'Monsieur' as values instead of just 'Mr.' and 'Mrs.' :

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

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

Cher ${lead.FirstName},

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

Chère ${lead.FirstName},

#else

Bonjour,

#end

So to summarise, I want to use Cher + first name to people whose title is either Mr. or Monsieur in the database.

Many thanks !

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

2 replies

Michael_Florin-2
Level 10
February 19, 2019

Probably not the most elegant solution ever, but this works:

#if ($greetCheck.contains('Mr.') or $greetCheck.contains('Monsieur'))

Cher ${lead.FirstName},

SanfordWhiteman
Level 10
February 19, 2019

Seek a collection-centric approach to make this easier to manage as more options are added:

#set( $greetingsBySalutation = {

["Mr.","Monsieur"] : "Cher ${lead.FirstName},",

["Mrs."] : "Chère ${lead.FirstName},",

[] : "Bonjour,"

} )

#foreach( $option in $greetingsBySalutation.keySet() )

#if( $option.contains($lead.Salutation) || $option.isEmpty() )

#set( $greeting = $greetingsBySalutation[$option] )

#break

#end

#end

${greeting}

Also, please highlight code when posting to the Nation so it's readable:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif