0

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.

  • for second one working is correct ? – pkharries Jan 21 '19 at 13:48
  • Yes, the second one is working correctly, the first one isn't (showing multiple blocks instead of one). In my opinion they say exactly the same, so that's why the question. – Silke Pinkhof Jan 21 '19 at 14:42
  • Why are you using non-numeric content block IDs? – Adam Spriggs Jan 21 '19 at 15:10
  • Also, where are @Region , @Type1 and @Type2 set? What values do they have prior to your conditionals? – Adam Spriggs Jan 21 '19 at 15:13
  • I adapted my question for clarification. Please note that code1 was working fine for 90% of the tests I did. It 'suddenly' started to show 2 blocks instead of 1, code was not touched. What happened is it showed a Europe and an America block at the same time. The blocks were correct for the other values, but obviously only one had to be shown, depending on region. – Silke Pinkhof Jan 21 '19 at 16:10
0

How was the email built? Content Builder? It's possible that the less than signs are causing issues. I have seen Content Builder try to treat less than signs as the first character of an html tag, which can cause erratic behavior. (Note the odd syntax highlighting in the attached screenshot)

|improve this answer|||||
  • It is working fine now too with the > < signs, so don't think that caused it. But anyway, if no-one has encountered differences in interpretation of ampscript, I'll just write it off as a one-time bug, since it's working now. MC can sometimes do that :-) – Silke Pinkhof Feb 4 '19 at 15:34

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.