0

I would like to insert a loop within a loop, this is the working first loop pulling in content from an external DE, how would I loop this over again?

---- updated working script below ------

%%[
var @rows, @row, @rowCount
var @lookupValue
set @lookupValue = AttributeValue("evtStart") 


set @lookupValue = "Friday" 
set @rows = LookupRows("WCOTW_final","evtStart", @lookupValue)
set @rowCount = rowcount(@rows)



if @rowCount > 0 then

    for @allDate = 1 to @rowCount do


/* --- set the var for the rows you want to display --- */
        var @ProductCode, @ProductName, @Credits
        set @row = row(@rows,@allDate) 
        set @ProductCode = field(@row,"ProductCode")
        set @ProductName = field(@row,"ProductName")
        set @Credits = field(@row,"Credits")

        if @allDate == 1 then
         outputline(concat("<p>"))
        endif
         

        ]%%

       <p style="text-align: left">
Product Name is %%=v(@ProductName)=%%
         <br>  
      Product Code : %%=v(@ProductCode)=%%
         <br><br>
         Credits = %%=v(@Credits)=%%
       </p>
        %%[ 
        if @allDate == @rowcount then
          outputline(concat("</p>"))
        endif
    next @i 
]%%
%%[ else ]%%
No rows
%%[ endif ]%%

2 Answers 2

3

Take a look at the function lookup.

You have a mistake at the stuff you are searching for. It cannot be Surname unless its being a value of the subscriber table. But even then i would write it differently

%%[ var @surname
set @surname = lookup('test_DE_name','Surname','SearchingColumn',"ValueYouWantToSearchFor" ) 
]%%

%%=v(@surname)=%%

I guess you understood something wrong and you would like to have it this way?

%%[ 
var @surname
set @surname = AttributeValue('surname') /* if the column is called surname */
set @OtherValue= lookup('test_DE_name','OtherColumn','Surname',@surname ) 
]%%

%%=v(@OtherValue)=%%

or this way?

%%[ 
var @subscriberkey
set @subscriberkey= AttributeValue('_subscriberkey')
set @surname= lookup('test_DE_name','Surname','subscriberkeyColumnname',@subscriberkey ) 
]%%

%%=v(@surname)=%%
2

I am not sure if you missed a "not" before "working". I make the assumption that it is not working. First and foremost, the Lookup function takes 4 parameters, not 3. https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/lookup.htm

%%[ var @surname set @surname = lookup('test_DE_name','Column to return', 'Surname',Surname ) ]%%

Secondly, Is the last Surname in below code a variable or do you try to hard code it?

%%[ var @surname set @surname = lookup('test_DE_name','Surname', Surname) ]%%

If it is a variable, make sure it has a value and has the @ as prefix.

%%[ var @surname set @surname = lookup('test_DE_name','Surname', @Surname) ]%%

If you are trying to hard code a value, you should surround it with ''

%%[ var @surname set @surname = lookup('test_DE_name','Surname', 'Surname') ]%%
1
  • Thanks for the answers for the original loop, can anyone suggest how I could loop within a loop
    – Factor33
    Commented Nov 21, 2019 at 15:28

You must log in to answer this question.

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