0

I am changing marketing emails to ampscript so there will be fewer steps in the future when editing emails across multiple languages.

The Data Extension this pulls from has subject lines in multiple languages. It pulls them correctly when I remove the "ELSE" statement below. However, I need a default English backup because my Data Extension does not identify every single country around the world.

The issue: I plug in this ampscript (example below). When I plug in the "ELSE" section below, ALL of the countries default to it. How do I set the "ELSE' statement to be secondary in the order of operations to the first Lookup section?

Here is example ampscript:

%%[

/*Define and set variables for Country*/

VAR @Country__c
SET @Country__c = [Country__c]

/*Lookup the subject line*/

VAR @Subject
IF NOT EMPTY (@Subject) THEN
SET @Subject = Lookup("Translated_Email1_DE","Subject","Country__c",@Country__c)

ELSE
SET @Subject = "Renew your subscription"

ENDIF
]%%

%%=v(@Subject)=%%

1 Answer 1

1

You made a mistake by checking the @Subject value, which is the lookup value and has not been populated yet.

Try something like this:

%%[

/* Define and set variables for Country */

VAR @Country__c 
SET @Country__c = AttributeValue("Country__c")

/* Lookup the subject line */

VAR @Subject

SET @Subject = Lookup("Translated_Email1_DE","Subject","Country__c",@Country__c)

IF EMPTY(@Subject) THEN

    SET @Subject = "Renew your subscription"
    
ENDIF 


]%%

%%=v(@Subject)=%%
6
  • Thank you. It looks like it is pulling the correct values for each subject in the Data Extension, but not that default ELSE value. It is not populating anything for countries (Country__c) not listed in my Country__c Data Extension column. It simply shows %%=v(@Subject)=%% as placeholder for those countries not identified in the Data Extension. Feb 2 at 18:41
  • @Bulldogstall I have updated the answer that now we use AttributeValue function to return the value from Country__c Data Extension column
    – Duc Le
    Feb 3 at 0:22
  • Hello @Duc Le. Thank you for AttributeValue. But the ELSE value still does not show for Country__c that does not exist.Would you know why? Thank you. For example, Mexico is a listed value for Country__c. Subject line populates for Mexico. But Canada is not a listed value for Country__c in the DE. It does not show the ELSE value above ("Renew your subscription"). Feb 5 at 19:14
  • @Bulldogstall I have updated the answer, it should work now.
    – Duc Le
    Feb 6 at 2:58
  • There was a logic issue in my old code, that it would use the lookup value result for the subject no matter the result was empty or not
    – Duc Le
    Feb 6 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .