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

Katia_Piton
Level 2

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

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 !

2 REPLIES 2
Michael_Florin
Level 10

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

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

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

Cher ${lead.FirstName},

SanfordWhiteman
Level 10 - Community Moderator

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

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