0

At the top of my newsletter I bring salutation and last name information but I don't want to show the value in Salutation directly. I used below Amscript but apparently it only checks the first value then brings "mevrouw" regardlessly.

Geachte %%[ IF [Salutation] == 'De weledelgeleerde heer' 
OR 'De weledelzeergeleerde heer' 
OR 'De hooggeleerde heer' THEN ]%% heer
 %%[ ELSE ]%% mevrouw %%[ ENDIF ]%% %%Last Name%%,  

Can we change this code something like this:

if salutation contains "heer" then bring "heer" else "mevrouw"

Thank you.

Adam Spriggs
  • 626
  • 8
  • 23
  • You'll get a lot more eyes on your SFMC questions over at [salesforce.stackexchange.com](http://salesforce.stackexchange.com), specifically with the [marketing-cloud](http://salesforce.stackexchange.com/questions/tagged/marketing-cloud) and [ampscript](http://salesforce.stackexchange.com/questions/tagged/ampscript) tags. – Adam Spriggs Nov 17 '20 at 12:54
  • Check this: [AMPscript - If Contains](https://salesforce.stackexchange.com/questions/92100/ampscript-if-contains) – astentx Nov 17 '20 at 13:53

2 Answers2

0

I'd recommend using the indexOf AMPscript function. I'd also use an init block to defensively check your raw personalization strings.

%%[ 

var @Salutation
var @lastName
set @Salutation = AttributeValue("Salutation")
set @lastName = AttributeValue("Last Name")
set @lastName = properCase(@lastName)

]%%

Geachte 

%%[ IF indexOf(@Salutation,'heer') > 0 then ]%%

  heer

%%[ ELSE ]%% 

  mevrouw 

%%[ ENDIF ]%% %%=v(@lastName)=%%,

Or inline:

%%[ 

var @Salutation
var @lastName
set @Salutation = AttributeValue("Salutation")
set @lastName = AttributeValue("Last Name")
set @lastName = properCase(@lastName)

]%%
Geachte %%=iif(indexOf(@Salutation,'heer') > 0,"heer","mevrouw")=%% %%=v(@lastName)=%%,
Adam Spriggs
  • 626
  • 8
  • 23
0

Thank you Adam. It works and I understand the logic better!