0

I'm stuck with my language variables, maybe someone can have a look and help? The code worked until I noticed that I have not one field to take into consideration (title) but the info might be in another field (salutation) too. Thanks a lot!

OLD code that works:

IF @language == "EN" THEN
IF @title == "Mrs" THEN
SET @quotesalutation = CONCAT("Dear Ms ",@lastname)
ELSE 
IF @

title == "Mr" THEN
SET @quotesalutation = CONCAT("Dear Mr ",@lastname)
ELSE
SET @quotesalutation = "Dear valued customer"
ENDIF
ENDIF
ENDIF

NEW (My try)

IF @language == "EN" THEN
IF (@title == "Mrs" OR @salutation "Ms.") THEN
SET @quotesalutation = CONCAT("Dear Ms ",@lastname)
ELSE 
IF (@title == "Mr" OR @salutation == "Mr.") THEN
SET @quotesalutation = CONCAT("Dear Mr ",@lastname)
ELSE
SET @quotesalutation = "Dear valued customer"
ENDIF
ENDIF
ENDIF
3

The code like you wrote it (with an added ==)

%%[
IF @language == "EN" THEN
    /* on the following line you forgot the == after @salutation)*/
    IF (@title == "Mrs" OR @salutation == "Ms.") THEN 
        SET @quotesalutation = CONCAT("Dear Ms ",@lastname) 
    ELSE 
        IF (@title == "Mr" OR @salutation == "Mr.") THEN
            SET @quotesalutation = CONCAT("Dear Mr ",@lastname) 
        ELSE 
            SET @quotesalutation = "Dear valued customer" 
        ENDIF 
    ENDIF 
ENDIF
]%%
%%=v(@quotesalutation)=%%

How you want it to be:

%%[
IF @language == "EN" THEN
    IF (@title == "Mrs" OR @salutation == "Ms.") THEN 
        SET @quotesalutation = CONCAT("Dear Ms ",@lastname) 
    ELSEIF (@title == "Mr" OR @salutation == "Mr.") THEN
        SET @quotesalutation = CONCAT("Dear Mr ",@lastname) 
    ELSE 
        SET @quotesalutation = "Dear valued customer"  
    ENDIF 
ENDIF
]%%
%%=v(@quotesalutation)=%%

What have i changed?

Instead of using three if statements, two were enough. You can just add an ELSEIF statement. You may ask yourself what an ELSEIF statement is, you can imagine it like this: It is like an extra condition that gets executed on the same level as the if statement, BUT only if the conditions before have not been true. If one of the previous conditions has met the criteria, it will execute the commands in that particular ELSEIF block and jump to the endif statement of the complete if block.

%%[
IF @var="a" THEN
    set @output = "Condition A is wonderful"
ELSEIF @var="b" THEN
    set @output = "Condition B is wonderful"
ELSEIF @var="c" THEN
    set @output = "Condition C is wonderful"
ELSEIF @var="d" THEN
    set @output = "Condition D is wonderful"
ELSE
    set @output = "None of my conditions has fit"
ENDIF
]%%
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.