one of my clients is trying to build content block trip recommendations based on subscribers attributes and defined logic which looks at boolean fields. The trip recommendations data is held in a non sendable DE.
I was able to build the logic and pull in the content based on the requirements but where I have issues is to actually limit the number of recommendations. For example they are trying to do one recommendations based on a trip budget + destination + a bunch of boolean fields that need to go in a specific order.
Code is below:
%%[
set @ContactID=AttributeValue('Contact ID')
set @emailAddress = AttributeValue('Email')
set @Destination = AttributeValue('Destination_NextTrip')
set @TripBudget= AttributeValue('TripBudget_NextTrip')
set @LengthDays= AttributeValue('LengthDays_NextTrip')
set @TravelPref= AttributeValue('TravelPref_NextTrip')
set @Mindful=AttributeValue('MindfulConsciousTraveller_FutureTravel_attitude')
set @Cruise=AttributeValue('Cruise_NextTravelExperience')
set @Outdoors=AttributeValue('Outdoors_NextTravelExperience')
set @CityBreak=AttributeValue('CityBreak_NextTravelExperience')
set @Romantic=AttributeValue('Romantic_NextTravelExperience')
set @rowss = LookupRows("Find your Trip BOZI","Default","1")
set @rowCounts = rowcount(@rowss)
if @rowCounts > 0 then
set @matchMindful =0
set @matchCruise = 0
set @matchOutdoors =0
set @matchCityBreak = 0
set @matchRomantic = 0
for @j = 1 to @rowCounts do
if (@matchMindful == 0 or @matchCruise == 0 or @matchOutdoors ==0 or @matchCityBreak == 0 or @matchRomantic == 0) then
set @rowj = row(@rowss, @j) /* get row based on counter */
set @DestinationNonSendable = field(@rowj,"Destination_NextTrip")
set @TripBudgetNonSendable = field(@rowj, "TripBudget_NextTrip")
set @LenghtDaysNonSendable = field(@rowj, "LengthDays_NextTrip")
set @name = field(@rowj, "name")
set @description = field(@rowj,"description")
set @LinkTrip=field(@rowj,"trip_url")
set @UrlFinal=RedirectTo(@LinkTrip)
set @defaultURl='https://www.trafalgar.com'
set @Image = field(@rowj,"imageURL")
set @nolink=''
set @MindfulNonSendable = field(@rowj,"MindfulConsciousTraveller_FutureTravel_attitude")
set @CruiseNonSendable = field(@rowj,"Cruise_NextTravelExperience")
set @OutdoorsNonSendable = field(@rowj,"Outdoors_NextTravelExperience")
set @CityBreakNonSendable = field(@rowj,"CityBreak_NextTravelExperience")
set @RomanticNonSendable = field(@rowj,"Romantic_NextTravelExperience")
if (@Destination == @DestinationNonSendable) and (@TripBudget == @TripBudgetNonSendable) and (@Mindful == 'True') and (@MindfulNonSendable == 'True') then
set @matchMindful =1
elseif (@Destination == @DestinationNonSendable) and (@TripBudget == @TripBudgetNonSendable) and (@Cruise == 'True') and (@CruiseNonSendable == 'True') then
set @matchCruise = 1
elseif (@Destination == @DestinationNonSendable) and (@TripBudget == @TripBudgetNonSendable) and (@Outdoors == 'True') and (@OutdoorsNonSendable == 'True') then
set @matchOutdoors=1
elseif (@Destination == @DestinationNonSendable) and (@TripBudget == @TripBudgetNonSendable) and (@CityBreak == 'True') and (@CityBreakNonSendable == 'True') then
set @matchCityBreak=1
elseif (@Destination == @DestinationNonSendable) and (@TripBudget == @TripBudgetNonSendable) and (@Romantic == 'True') and (@RomanticNonSendable == 'True') then
set @matchRomantic = 1
else
set @matchMindful =0
set @matchCruise = 0
set @matchOutdoors =0
set @matchCityBreak = 0
set @matchRomantic = 0
endif /* closing the if/elseif matching loop */
endif /* this closes if @matchMindful == 0 and the other ==0 */
if (@matchMindful==1 or @matchCruise ==1 or @matchOutdoors ==1 or @matchCityBreak==1 or @matchRomantic ==1) then ]%%
<br>
Mindful from Sendable DE: %%=v(@Mindful)=%% || Mindful from non sendable DE: %%=v(@MindfulNonSendable)=%%
<br>
Cruise from sendable DE: %%=v(@Cruise)=%% || Cruise from non sendable DE: %%=v(@CruiseNonSendable)=%%
<br>
Outdoors from sendable DE: %%=v(@Outdoors)=%% || Outdoors from Non Sendable DE: %%=v(@OutdoorsNonSendable)=%%
<br>
City Break from sendable DE: %%=v(@CityBreak)=%% || City Break From non sendable DE: %%=v(@CityBreakNonSendable)=%%
<br>
Romantic from sendable DE: %%=v(@Romantic)=%% || Romantic from Non Sendable DE: %%=v(@RomanticNonSendable)=%%
<br>
<br>
This is block 1 stuff match on destinaton and budget and <b>a match on one of the above</b>:
<br>
<br>
<br>
<br>
Destination from Sendable DE: %%=v(@Destination)=%% ||| <br>Destination from non sendable DE: %%=v(@DestinationNonSendable)=%%
<br>
<br>
Budget from Sendable DE: %%=v(@TripBudget)=%% ||| <br> Budget from non sendable DE: %%=v(@TripBudgetNonSendable)=%%
<br>
name: %%=v(@name)=%%
<br>
%%[ endif /* closes (@matchMindful==1 or @matchCruise ==1 or @matchOutdoors ==1 or @matchCityBreak==1 or @matchRomantic ==1) */ ]%%
%%[ next @j ]%%
%%[ endif /* closes rowcounts */ ]%%
With this I am able to bring the correct articles that match either the branches in the logic but I need to be able to "stop" the matching process in the for loop once 1 match has been found. I have added a print screen of what I get in the send preview. I hope it makes sense.
I had a similar question last year where I was recommended to add the switch break in the for loop @j== @rowcounts but if I add it in my code I don't get any results.
thank you, Giulietta