0

I have condition if "color" is red or purple and "year" greater than "number", it would show google link, otherwise if not within those categories it would show facebook link.

    SET @Number = 2023
    SET @Year = 2022
    SET @Color = [Color]
            
    if (IndexOf(@Color,'red') > 0 or IndexOf(@Color,'purple') > 0) and @Year > @Number then
    SET @Link = "https://google.com/"
    
    else
           
    SET @Link = "https://www.facebook.com/"
          
    endif

In my DE, I have "red B", so depend on the code instead of showing google.com or Facebook.com, it shows default link: https://user-content.s10.sfmc-content.com/

What did I do wrong? why it's showing https://user-content.s10.sfmc-content.com/ ? eventhough I have %%=RedirectTo(@Link)=%%

1 Answer 1

0

You have multiple issues in the code. All the URLs need to start with 'https://' in order to work properly. Hence you will need to update your @link variables.

You don't show your link tag, buy you need to use the RedirectTo function in your href tag. This function is required when using the HTML hyperlink tag in emails when the hypertext reference (href) attribute is either an attribute or a variable and the hyperlink is a tracked email link.

Additionally, you must also update the IndexOf functions, as you are not calling the variables correctly. Instead of using: IndexOf(Color,'red'), you must do IndexOf(@Color,'red')

2
  • Thanks for your comment, for the url I just forgot to add https on the sample code, but it's there on my real code. For the hyperlink tag also is there, but not shown in the sample code. For IndexOf, I just made an edit, adding @ on the variable, but still not working
    – Uss
    May 16 at 18:22
  • @Uss - please provide more context and share your actual code, as seeing parts of it with typos, does not give us any good basis for helping you... May 16 at 18:54

You must log in to answer this question.

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