0

I have DE lists like this for "Fruits" category:

"Apple", "Apple A", "Apple 2", "Apple red", "Apple green", "Apple CA", "Mango", "Mango Lala", "Mango B", "Mango White", "Mango special", "Mango yes" etc

And for "Year" category:

"2023", "2024", "2025", so on

Basically, I want to show if the fruits name is listed and year is correct then it would specific link, otherwise if fruits name not within in that category and year less than 2023 then it would show default link.

My code:

var @lookupValue set @lookupValue = [Fruits] SET @Fruits= [Fruits] set @Year= [Year] SET @LinkDefault = "google.com" if IndexOf(Fruits,'Apple') > 0 or IndexOf(Fruits,'Apple red') > 0 and @Year >= 2023 then SET @LinkSE = lookup('FruitsJourney_Links', 'LinkHero' ,'Fruits', @lookupValue) SET @Link1 = lookup('FruitsJourney_Links', 'Link1' ,'Fruits', @lookupValue) SET @Link2 = lookup('FruitsJourney_Links', 'Link2' ,'Fruits', @lookupValue) SET @Link3 = lookup('FruitsJourney_Links', 'Link3' ,'Fruits', @lookupValue) elseif IndexOf(Fruits,'Mango') > 0 or IndexOf(Fruits,'Mango red') > 0 and @Year >= 2023 then SET @LinkSE = lookup('FruitsJourney_Links', 'LinkHero' ,'Fruits', @lookupValue) SET @Link1 = lookup('FruitsJourney_Links', 'Link1' ,'Fruits', @lookupValue) SET @Link2 = lookup('FruitsJourney_Links', 'Link2' ,'Fruits', @lookupValue) SET @Link3 = lookup('FruitsJourney_Links', 'Link3' ,'Fruits', @lookupValue) else @Fruits != [Fruits ] and @Year <= 2022 then SET @LinkSE = @LinkDefault SET @Link1 = @LinkDefault SET @Link2 = @LinkDefault SET @Link3 = @LinkDefault endif 

I think my condition is correct, however,the default link doesn't work, can anyone check what is the issue with my code?

Thanks.

4
  • The @lookupvalue and @ModelYear variables have not been set, at least not in the piece of code you provided Commented May 15, 2023 at 21:24
  • @zuzannamj I just made an edit, adding the lookupvalue and year Commented May 15, 2023 at 21:29
  • Are the years listed in an Array? In your sample code above, it reads: "2023", "2024", "2025" and so on Is it stored as an Array or a String? Either one won't work given the condition if it's looking for >= conditional. @Year >= 2023 Just a thought. Commented May 15, 2023 at 23:08
  • Thanks for your comment, it's not an array, I just add the year to show sample. My conditon is also like that, but still does't work Commented May 15, 2023 at 23:21

2 Answers 2

0

It looks like if the last "else" statement was changed to "elseif" the default links would show.

elseif @Fruits != [Fruits ] and @Year <= 2022 then 
1
  • Unfortunately doesn't work. I'm not sure what's the issue,, Commented May 16, 2023 at 14:56
0

An ELSE statement does not receive any evaluation criteria.

If your goal is to evaluate several conditions using tiered logic, then if none are met assign default values, your last evaluation line is just "ELSE":

ELSE SET @LinkSE = @LinkDefault

SET @Link1 = @LinkDefault SET @Link2 = @LinkDefault SET @Link3 = @LinkDefault 

ENDIF

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.