3

I have this ampscript:

%%[
var @id, @reference221, @reference222, @Apointer221, @ASKU221, @Apointer222, @ASKU222, @reference223, @reference224, @content222

SET @id = [email]
SET @reference221 = LookupRows("case2_2step1", "email", @id)

IF RowCount(@reference221) == 2 THEN

SET @reference222 = LookupOrderedRows("case2_2step1", 2, "email", "email", @id)
SET @Apointer221 = Row(@reference222, 1)
SET @ASKU221 = Field(@Apointer221, "sku")
SET @Apointer222 = Row(@reference222, 2)
SET @ASKU222 = Field(@Apointer222, "sku")
SET @reference223 = LookupRows("case2_2step3", "email", @id, "artikelnummer", @ASKU221)
SET @reference224 = LookupRows("case2_2step3", "email", @id, "artikelnummer", @ASKU222)

ENDIF

IF (@reference223 == 1 AND @reference224 == 1) THEN SET @content222 = 'A'
ELSEIF (@reference223 == 1 AND @reference224 > 1) OR (@reference223 > 1 AND @reference224 == 1) OR (@reference223 > 1 AND @reference224 > 1)
THEN SET @content222 = 'B' ENDIF

]%%

%%= v(@id) =%% <br>
%%= RowCount(@reference221) =%% <br>
%%= v(@ASKU221) =%% <br>
%%= v(@ASKU222) =%% <br>
%%= RowCount(@reference223) =%% <br>
%%= RowCount(@reference224) =%% <br>
%%= v(@content222) =%% <br>

All variables return values that I expect but somehow this @content222 returns nothing even though the variables (@reference223 and reference224) fulfil the IF ELSE condition. I'm banging my head on this. If anybody notice anything wrong please help

  • Is the artikelnummer field in your data extension a number or text data type? – Kelly J Andrews Jan 15 '14 at 12:40
  • the artikelnummer is text – Faris Jan 15 '14 at 12:46
1

In order to match data in the data extension, you need will need to ensure the types are also the same. Since artikelnummer is set to text, you would want to change you IF ELSE statement to the following:

IF (@reference223 == '1' AND @reference224 == '1') THEN 
  SET @content222 = 'A'
ELSEIF (@reference223 == '1' AND @reference224 > '1') OR (@reference223 > '1' AND @reference224 == '1') OR (@reference223 > '1' AND @reference224 > '1')
THEN 
  SET @content222 = 'B' 
ENDIF

Edit Turned out to be missing RowCount -

IF RowCount(@reference223) == 1 AND RowCount(@reference224) == 1 THEN 
   SET @content222 = 'A'
ELSEIF (RowCount(@reference223) == 1 AND RowCount(@reference224) > 1) OR (RowCount(@reference223) > 1 AND RowCount(@reference224) == 1) OR (RowCount(@reference223) > 1 AND RowCount(@reference224) > 1) THEN 
   SET @content222 = 'B'
  • I tried and @content222 always return B. I dont think the problem is in data type because when I call %%= RowCount(@reference223) =%% and %%= RowCount(@reference224) =%% it returns a correct value (in my case 1, 2 or 3) the returned value from the RowCount will always int if im not mistaken – Faris Jan 15 '14 at 12:59
  • Your are passing a number in the if statement, and the field is a string. – Kelly J Andrews Jan 15 '14 at 13:06
  • yes you are right, my mistake. your answer dont fix the problem but pointed out my mistake. thanks – Faris Jan 15 '14 at 13:27
1

Sorry its my mistake. I forget to put RowCount() function in the if else statement so the @reference223 and @reference224 contain text

here is the correct form of the if else statement

IF RowCount(@reference223) == 1 AND RowCount(@reference224) == 1 THEN SET @content222 = 'A'
ELSEIF (RowCount(@reference223) == 1 AND RowCount(@reference224) > 1) OR (RowCount(@reference223) > 1 AND RowCount(@reference224) == 1) OR (RowCount(@reference223) > 1 AND RowCount(@reference224) > 1)
THEN SET @content222 = 'B'
  • Yep, I wasn't even looking at that portion. That would be the issue – Kelly J Andrews Jan 15 '14 at 13:36
  • When you can, be sure to mark this as answered as well! – Kelly J Andrews Jan 16 '14 at 23:02

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.