0

I have two Data Extensions one is a Sendable DE with contacts and an array of the products they have. The second is a NonSendable DE with the product information on it.

I want to pull in a list of products tied to the user, so if the product array contains 'ABC' then LookUp 'ABC on the Product DE and grab the information associated to it. Rinse and Repeat for every product.

USER DE

EmailAddress              | Products
[email protected]          | product-one, product-two, product-ten
[email protected]          | product-two, product-six, product-twentyone

USER DE

fundKey              | fundTitle
product-one          | Product One
product-two          | Product Two

CURRENT CODE

%%[
var @productName, @rows, @row, @rowCount, @product, @i, @productTitle

set @productName = Products
set @rows = BuildRowsetFromString(@productName,",")
set @rowCount = rowCount(@rows)

if @rowCount > 0 then
  for @i = 1 to @rowCount do
  
    set @row = row(@rows, @i)
    set @product = field(@row,1)
    set @product = trim(@product)
    set @productTitle = Lookup("TSI_Funds_Info_POC","fundTitle","fundKey", @product)
    
    ]%%
    <br>%%=v(@i)=%% 
         <a href="https://www.westernsouthern.com/touchstone/mutual-funds/%%=v(@product)=%%">%%=Trim(@productTitle)=%%</a> | 
         <a href="https://www.westernsouthern.com/-/media/files/touchstone/fund-literature/%%=v(@product)=%%-fact-sheet.pdf">PDF</a> | 
         <a href="https://www.westernsouthern.com/-/media/files/touchstone/fund-literature/%%=v(@product)=%%-commentary.pdf">PDF</a>

    %%[
  next @i ]%%
%%[ else ]%%
No Products Found
%%[ endif ]%%

I know I'm close... just messing up how I'm doing the LookUp... thanks if you can help close the gap for me.

UPDATE Updated Code... have the first Title Inputting... it's just not repeating for the rest.

1 Answer 1

3

Could be the spaces after the commas in your Products string. You can mitigate that by inserting a trim() function in your loop before you use it to retrieve the title:

%%[

var @productNames, @rows, @row, @rowCount, @product, @i, @productTitle

set @productNames = AttributeValue("Products")

if not empty(@productNames) then

    set @rows = BuildRowsetFromString(@productNames,",")
    set @rowCount = rowCount(@rows)

    if @rowCount > 0 then

      for @i = 1 to @rowCount do

        set @row = row(@rows, @i)

        set @product = field(@row,1)
        set @product = trim(@product)

        set @productTitle = Lookup("TSI_Funds_Info_POC","fundTitle","fundKey", @product)

        ]%%

            <br>%%=v(@i)=%% 
            <a href="https://www.url.com/touchstone/funds/%%=v(@product)=%%">%%=v(@productTitle)=%%</a> | 
            <a href="https://www.url.com/-/media/files/fund-literature/%%=v(@product)=%%-fact-sheet.pdf">PDF</a> | 
            <a href="https://www.url.com/-/media/files/fund-literature/%%=v(@product)=%%-commentary.pdf">PDF</a>

        %%[

      next @i 

    else 

      output(concat("<br>no products found"))

    endif 
    
else 
    output(concat("<br>empty productNames"))
endif

]%%

You must log in to answer this question.

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