2

I am creating a dynamic sender profile retrieving info from a content area with ampscript. The current code is based on values within salesforce.

The current content is working although when I add additional parameters for language I am receiving errors the code which is receiving errors is:

%%[
Var @n, @EN, @FR
SET @EN = "English xxx"
SET @FR = "French yyy"
SET @n = Lookup("ENT.Salesforce_User_Data", "Name", "id", LongSFID([Relationship Owner SFID]))
]%%

%%[ IF region == "Atlantic" OR region == "Ontario" OR region == "Quebec" OR region == "Western Canada" OR region == "Institutional" THEN ]%%
    %%=v(@n)=%%
%%[ ELSEIF region == "" OR region == "Default" OR region == "Discount" OR region == "Other " AND (language != "French") THEN ]%% 
    %%= v(@EN) =%% 
%%[ ELSE ]%%
   %%= v(@FR) =%%
%%[ ENDIF ]%%

When testing the display name which should be French yyy is English xxx although when replying the correct name is displayed.

  • I'm not seeing an error message in your question. – Adam Spriggs Nov 28 '16 at 21:35
1

I think you're missing a pair of parentheses in the elseif.

Also, I'd utilize the AttributeValue() function to ensure that the language, region and Relationship Owner SFID attributes are defined.

You can use the output() function to keep from having to open and close AMPScript blocks

%%[

var @n, @EN, @FR, @region, @ownerSFID, @language

set @n = Lookup("ENT.Salesforce_User_Data", "Name", "id", LongSFID(@ownerSFID))
set @EN = "English xxx"
set @FR = "French yyy"
set @region = AttributeValue("region")
set @ownerSFID = AttributeValue("Relationship Owner SFID")
set @language = AttributeValue("language")

]%%

%%[

if @region == "Atlantic" OR @region == "Ontario" OR @region == "Quebec" OR @region == "Western Canada" OR @region == "Institutional" then

  output(concat(@n))

elseif (empty(@region) OR @region == "Default" OR @region == "Discount" OR @region == "Other") and @language != "French" then

  output(concat(@en))

else

  output(concat(@fr))

endif

]%%
  • I figured out the issue it was not my coding although its not as clean as yours. The issue was the email address stated as a variable for the content area which I use to for the From Email of Sender. – Cheryl M Nov 29 '16 at 16:43

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.