0

I cannot figure out how to write an ampscript in order to bring the content from a non sendable data extension in my email content; in this DE i have the trip name, trip URL & trip image and I want to be able to use these in my email and should work for all data extensions that I am sending to.

I have created the Trip Name as a profile attribute and written the following code so far:

%%[VAR @TripName,@TripURL2,@TripImage2

SET @TripName=AttributeValue('Trip Name')
SET @rows = LookupRows("Trip Data","Trip Name",@TripName)
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 @TripName2 = field(@row,"Trip Name")
    set @TripURL2 = field(@row,"Link URL")
    set @TripImage2 = field(@row,"Image URL")

    ]%%

    <br>Row %%=v(@i)=%% 
<br>Trip Name: %%=v(@TripName2)=%%
<br>Link URL %%=v(@TripURL2)=%%
<br>Image URL %%=v(@TripImage2)=%%

    %%[

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

of course when i do the send preview i get the no rows found message; I am trying to use this non sendable DE in order to build my email content from.

What am I doing wrong?

3
  • Try hard-coding a value as a test: SET @TripName = "Best of Belgium". Still no rows found?
    – Mark G
    Aug 16, 2019 at 5:46
  • I did that and i get only the first row. I need both rows to be evaluated.
    – Wallace
    Aug 16, 2019 at 5:49
  • Good so far... the next debugging test to try... right after you set @TripName, output it to make sure AttributeValue("Trip Name") is actually returning a value: Output(Concat("Trip Name: ", @TripName)).
    – Mark G
    Aug 16, 2019 at 5:53

1 Answer 1

2

When you use the AttributeValue function SET @TripName=AttributeValue('Trip Name'), you are referencing either a profile attribute, or a column in s Sendable Data Extension used at the time of sending.

So make sure that in your sendable Data Extension there is also a column called 'Trip Name', like for example here:

enter image description here

Also, make sure you are previewing correctly against a subscriber: https://help.salesforce.com/articleView?id=mc_es_perform_subscriber_preview_test_send.htm&type=5

Your AMPscript looks correct, so it's either a problem with missing 'Trip Name' column in your Sendable Data Extension or the way you perform a Subscriber Preview.

If what you are trying to achieve is pulling all the rows form your Data Extension, the answer how to do this is in this thread: Exacttarget data extension - How to retrieve all rows in AMPScript

You must log in to answer this question.

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