0

In my sendable data extension I have 1 or more possible destinations separated by ; For my use case I need to pull the first 2 destinations from the sendable DE.

I am referencing these destinations into a non sendable data extension where I have different blog articles and multiple images. I want to be able to limit the number of articles to 3 from the non sendable data extension for either the first location or second location from the sendable Data extension. (depending on the combination of destinations I can have different number of articles pulled in my email)

Issue I am facing is that I can either bring all the articles (as in the script below) or I am able to limit it to 1 but I am not sure how I can re-write the script to show me 3 articles for either destination 1 or destination 2 in my Data Extension.

I have attached an example of my sendable DE & non sendable I am referencing.

%%[

SET @Location=AttributeValue('Destination')
SET @virgula=';'

if IndexOf(@Location,@virgula) > 0 then 

     SET @rs = BuildRowsetFromString(@Location,';')
     SET @PrimaryLocation = Field(Row(@rs,1),1)
     SET @SecondaryLocation = Field(Row(@rs,2),1)
else 
SET @PrimaryLocation=@Location
SET @SecondaryLocation=@Location

endif 

]%%

Primary location: %%=v(@PrimaryLocation)=%%
<br>
Secondary location: %%=v(@SecondaryLocation)=%%<br><br>


%%[SET @rows = LookupRows("PBN Cris Reference","Default","1")
set @rowCount = rowcount(@rows)
if @rowCount > 0 then

 FOR @i = 1 to @rowCount do
 set @row = row(@rows, @i) /* get row based on counter */
 set @Article = field(@row,"Article")
 set @Image = field(@row,"Image")
 set @Destination2=field(@row,"Destination")
 
/* checking for the match on location */
  if (@PrimaryLocation == @Destination2) or (@SecondaryLocation == @Destination2) then
        SET @match = 1]%%

Article: %%=v(@Article)=%%<br>
Image: %%=v(@Image)=%% <br><br>

        
      %%[ENDIF
       NEXT @i 
ELSE
]%%
  


%%[  
ENDIF
]%%

2 Answers 2

1

I think the problem is that you are looking up records in the PBN Cris Reference DE by the Default field which is set to 1 for all records:

SET @rows = LookupRows("PBN Cris Reference","Default","1")

Instead, try looking up by the destination:

SET @rowsPrimary = LookupRows("PBN Cris Reference","Destination",@PrimaryLocation)
SET @rowsSecondary = LookupRows("PBN Cris Reference","Destination",@SecondaryLocation)

then, do a rowcount for both @rowsPrimary and @rowsSecondary and you will be able to build a condition with a loop for displaying as many articles as you wish (below is just an example of the logic as I am typing this quickly and might have overlooked something):

%%[
...

if rowcount(@rowsPrimary) >= 3 then
 FOR @i = 1 to 3 do /* control the number of articles by amending the end loop condition */
 set @row = row(@rowsPrimary, @i) /* get row based on counter */
 set @Article = field(@rowsPrimary,"Article")
 set @Image = field(@rowsPrimary,"Image")

]%%

Article: %%=v(@Article)=%%<br>
Image: %%=v(@Image)=%% <br><br>

        
      %%[next @i 
elseif rowcount(@rowsSecondary) >= 3 then
 FOR @i = 1 to 3 do /* control the number of articles by amending the end loop condition */
 set @row = row(@rowsSecondary, @i) /* get row based on counter */
 set @Article = field(@rowsSecondary,"Article")
 set @Image = field(@rowsSecondary,"Image")
]%%

Article: %%=v(@Article)=%%<br>
Image: %%=v(@Image)=%% <br><br>

        
      %%[next @i 
else]%%
No articles to display.
%%[ endif ]%%
0

Thanks @zuzannamj. I opted in the end for another solution where I matched the data via SQL on the first 4letters from the primary location to either city or country in my non sendable DE; so i had a resulting data extension with multiple entries per subscriber key for each of the matches; then in the SQL i could limit the number of articles per each subscriber key; then in the email i just pulled via rowlookups all the instances i needed from this SQL data extension.

You must log in to answer this question.

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