I wrote a piece of Ampscript to check out data in a Triggered Send Data Extension and show specific content blocks related to the different choices you made on an LPA.
It's basically a list of IF statements, first by region, then by type. I wrote every single choice out like this:
%%[ IF @Region == "Europe" AND @Type1 == "<100" AND @Type2 == "Hot" THEN ]%%
%%=ContentBlockbyID("0001")=%%
%%[ endif ]%%
%%[ IF @Region == "Europe" AND @Type1 == "<100" AND @Type2 == "Cold" THEN ]%%
%%=ContentBlockbyID("0002")=%%
%%[ endif ]%%
%%[ IF @Region == "America" AND @Type1 == ">100" AND @Type2 == "Hot" THEN ]%%
%%=ContentBlockbyID("0003")=%%
%%[ endif ]%%
%%[ IF @Region == "America" AND @Type1 == ">100" AND @Type2 == "Cold" THEN ]%%
%%=ContentBlockbyID("0004")=%%
%%[ endif ]%%
It worked fine at first, but after a while it started showing 2 blocks, 1 correct one, one faulty one. Verified everything, my content blocks were correctly mentioned in my code; no double calling of a block in the same situation happened.
So what I did, is change the code to following:
%%[ IF @Region == "Europe" THEN ]%%
%%[ IF @Type1 == "<100" AND @Type2 == "Hot" THEN ]%%
%%=ContentBlockbyID("0001")=%%
%%[ endif ]%%
%%[ IF @Type1 == "<100" AND @Type2 == "Cold" THEN ]%%
%%=ContentBlockbyID("0002")=%%
%%[ endif ]%%
%%[ endif ]%%
%%[ IF @Region == "America" THEN ]%%
%%[ IF @Type1 == ">100" AND @Type2 == "Hot" THEN ]%%
%%=ContentBlockbyID("0003")=%%
%%[ endif ]%%
%%[ IF @Type1 == ">100" AND @Type2 == "Cold" THEN ]%%
%%=ContentBlockbyID("0004")=%%
%%[ endif ]%%
%%[ endif ]%%
Restructuring this code by putting the Region outside of the contentblock defining IF statement fixed the issue.
But I don't really understand what happened here, why my code is being interpreted differently, because it's saying the same thing.
Does anyone have any experience with something like this?
UPDATE: Defining variables:
They are numeric codes, just put CBID1 (contentblockid 1) as an example. Could be ContentBlockID 3745 for example.
Defining variables:
%%[
VAR @SubKey, @Region, @Type1, @Type2
SET @SubKey = SubscriberKey
SET @Region = Region
SET @Type1 = Type1
SET @Type2 = Type2
]%%
Example values:
Values Region: 'Europe' ; 'America'
Values Type1: '>100' ; '<100'
Values Type2: 'Hot' ; 'Cold'
Fields Region, Type1 and Type2 are fields in my DE i'm using for sending.
Please note that actual names and data have been replaced by dummy names and data because of corporate guidelines. Code stays the same, only names of fields and data values are not literal.
@Region
,@Type1
and@Type2
set? What values do they have prior to your conditionals?