1

I have an email that is in build with a large amount of IF statements contained within the email.

The concept of the email is that if the 10 item fields are populated then show all 10 within the body of the email via if statments which will display the name and price of the item.

I am encountering a strange issue whereby if i try to render a preview with all 10 of the items populated. the 6th item if statement is ignored every time and only 9 rows of text display.

I have the fields set as variables like so:

SET @item1 = AttributeValue("item1")

SET @item2 = AttributeValue("item2")

SET @item3 = AttributeValue("item3")

SET @item4 = AttributeValue("item4")

SET @item5 = AttributeValue("item5")

SET @item6 = AttributeValue("item6")

SET @item7 = AttributeValue("item7")

SET @item8 = AttributeValue("item8")

SET @item9 = AttributeValue("item9")

SET @item10 = AttributeValue("item10")

Within the body of the email i turn the display of text on and off by referncing values in these fields.

The email is built in sections so the 10 IF statments are contained within one wrapping if statement to turn on and off the area dependent on

%%[IF @DisplayPurchased == 'True' THEN]%%


    %%[ IF @item1 == 'Purchased' THEN]%%
    %%=Propercase(@item1Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item2 == 'Purchased' THEN]%%
    %%=Propercase(@item2Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item3 == 'Purchased' THEN]%%
    %%=Propercase(@item3Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item4 == 'Purchased' THEN]%%
    %%=Propercase(@item4Name)=%%<br>
    %%[ENDIF]%%

    %%[ IF @item5 == 'Purchased' THEN]%%
    %%=Propercase(@item5Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item6 == 'Purchased' THEN]%%
    %%=Propercase(@item6Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item7 == 'Purchased' THEN]%%
    %%=Propercase(@item7Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item8 == 'Purchased' THEN]%%
    %%=Propercase(@item8Name)=%% <br>
    %%[ENDIF]%%

    %%[ IF @item9 == 'Purchased' THEN]%%
    %%=Propercase(@item9Name)=%% <br>
    %%[ENDIF]%%

    %%[IF @item10 == 'Purchased' THEN]%%
    %%=Propercase(@item10Name)=%% <br>
      %%[ENDIF]%%

  %%[ENDIF]%%

All item field values 1-10 are set to 'Purchased'.

Expected outcome is for all 10 to display, only 9 do.

Testing i have done:

  • Changed item 6 attribute value to = AttributeValue("item7") which results in all 10 items showing.
  • Cleared and re-uploaded data into the data extension for item 6, copied directly from other items to ensure 'Purchased' is identical.
  • Rebuilt the data extension from scratch.
  • Pasted the variable of item 6 %%=v(@item6)=%% to the email in text form. It comes up as 'Purchased' just as expected.
  • Created and referenced a new field for the item 6 set statement and changed the variable referenced within item6.
  • Placed the item 6 if statement by itself at the top of the email. If the variable @item6 is SET @item6 = = AttributeValue("item6") it DOES NOT display. If this is set to AttributeValue("item7") it does display..

    %%[ IF (@item6 == 'Purchased') THEN]%% %%=Propercase(@item6)=%%
    %%[ENDIF]%%

  • set @item6 field in the DE to 'Purchase' instead of 'Purchased' and it shows

Does SFMC have a limit of how many identical field values can be searched in an email even across separated if statements? it appears that no matter how it comes through if there are 10 of the same value looked at across any if statements in the email that SFMC will ignore the 6th of the 10 in total in my example above ^

Any assistance greatly appreciated.

2
  • You have a bracket in your 10th if that is not supposed to be there ) Sep 7, 2019 at 7:00
  • Looks like that was just a leftover from my copy pasting into stackexchange. Sadly not the cause of the oddity i'm experiencing. updated original post to remove this Sep 7, 2019 at 13:28

2 Answers 2

1


I was able to reproduce your problem with the below AMPscript:

%%[
SET @item1 = 'Purchased'
SET @item2 = ''
SET @item3 = 'Purchased'

SET @item1Name = 'ITEM NAME A'
SET @item2Name = 'Item Name B'
SET @item3Name = 'Item NAME C'

FOR @m = 1 to 3 do
  SET @attribute = TreatAsContent(Concat("%%=v(@item",@m,")=%%"))
  IF @attribute == "Purchased" THEN
  SET @product = TreatAsContent(Concat("%%=v(@item",@m,"Name)=%%"))
  OutputLine(Concat(Propercase(@product), '<br>'))
  ENDIF
next @m
]%%


Result:

Item Name A
Item Name C


Reverting to your original code - and assuming the "@item#Name" is coming from another part of your code - the following should work:

%%[
FOR @m = 1 to 10 do
  SET @attribute = Concat('"item',@m,'"')
  IF AttributeValue(@attribute) == "Purchased" THEN
  SET @product = TreatAsContent(Concat("%%=v(@item",@m,"Name)=%%"))
  OutputLine(Concat(Propercase(@product), '<br>'))
  ENDIF
next @m
]%%


Note: SET @attribute function changed and the For Loop is increased to 10 to meet your original question needs.
Hope this works for you :)

2
  • Hi Cameron, thanks for the secondary solution i will give this a try. Oddly my issue occurring with item 6 is that the value all items are the same 'Purchased' however my IF statements are not able to recognise this only for item 6 field. Sep 8, 2019 at 2:53
  • Glad you were able to get a positive resolution Nick! Happy to help if you have any future issues. Sep 8, 2019 at 5:45
1

It turns out the data provided via API had an accidental space within the data only in the 6th field of the 10 which was not picked up in SFMC. Only upon taking it out of SFMC and into a text editor was this picked up.

1
  • 2
    What I usually do to help safeguard against this is to use lowercase and trim when comparing. E.g. IF TRIM(LOWERCASE(@item6)) == "purchase" then this will remove case sensitivity and any floating spaces from front/end. Now, if you are outputting that var, you will need to adjust that separately as that is only for the comparison. Sep 9, 2019 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .