3

I'm trying to add a word, as well as a comma but only if the next field isn't empty. If it is empty then I just want to add a word because it's the end of a list. My problem is if the field is empty, it won't show my word and Product1.

I'm sure I'm missing something simple but I can't figure it out. I had it as an Else but it kept showing the word and not the product1.

%%[ if not empty(@Product2) then ]%% 
  not empty 
%%= v(@Product1) =%%,
%%[ if empty(@Product2) then ]%% 
  empty 
%%= v(@Product1) =%%%%[ENDIF]%%%%[ENDIF]%%

What am I missing?

1
  • 2
    Welcome to SFSE, please take some time to read How to Ask and take the tour. Once you have done so, could you please update your post title with a relevant title? thanks!
    – glls
    Commented Feb 6, 2018 at 17:41

1 Answer 1

4

You should be able to do this in one line with an iif() (inline-if) statement:

%%=v(@Product1)=%%%%=iif(not empty(@product2), concat(", ", @product2), "")=%%

Of without the iif():

%%=v(@Product1)=%%
%%[

if not empty(@product2) then

  ouput(concat(", ", @product2))

endif

]%%
2
  • Thank you for your help. Are there any examples on how to do the one line with iif()?
    – Angela1044
    Commented Feb 6, 2018 at 20:01
  • I used an iif() in my example. Commented Feb 6, 2018 at 21:34

You must log in to answer this question.

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