0

I am trying to create a custom email message using IF THEN statement that reads an Attribute through our DE. The message should pertain to what "card tier" the client is. Salesforce keeps telling me that the code is not closed properly, at this point I am unsure what to do or if this is the right string function.

%%[
var @CardTierDesc
set @CardTierDesc = [Card Tier Desc]

]%%

  
IF @action == "AttributeValue('Emerald')" THEN ]%% 
<p>This is the Emerald message</p> 

%%[ IF @action == "AttributeValue('Diamond')" THEN ]%% 
<p>This is the diamond messge.</p> 

%%[ IF @action == "AttributeValue('Crown')" THEN ]%% 
<p>CROWN IS THE RULER</p>
  
%%[ENDIF]%%
1
  • Where is the value for @action set? Mar 25, 2021 at 21:38

1 Answer 1

1

I think you may be misunderstanding the purpose of the AttributeValue function. It's meant to retrieve and validate contextual variables.

You're also missing an opening block tag (%%[) before the first condition.

Assuming that @action should be @CardTierDesc, you could do something like this:

%%[

var @CardTierDesc
set @CardTierDesc = AttributeValue("Card Tier Desc")

]%%

%%[ IF @CardTierDesc == "Emerald" THEN ]%% 

  <p>This is the Emerald message</p> 

%%[ ELSEIF @CardTierDesc == "Diamond" THEN ]%% 

  <p>This is the diamond message.</p> 

%%[ ELSEIF @CardTierDesc == "Crown" THEN ]%% 

  <p>CROWN IS THE RULER</p>
  
%%[ENDIF]%%

Also, if you're using Sublime Text for editing your email code, the new AMPscript Syntax Highlighter will help you validate the simple language constructs.

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.