0

I'm having trouble with the ampscript LookupRows to grab data from a synchronized data extension. Here is what I have so far:

%%[

var @rows, @row, @first

set @rows = LookupRows("Contacts","FirstName", @first)
set @row = Row(@rows, 1)

]%%


%%=ProperCase(@first)=%%

In this case I'd like to display the First Name which exists in the Contacts synchronized data extension but I am missing a piece of the puzzle. Any advice?

2 Answers 2

2

In addition to what Eduardo mentioned, you're missing a value to use to retrieve the row from your Data Extension.

%%[

var @rows, @row, @contactID, @first

set @contactID = AttributeValue("ContactID")  /* you have to set this first */
set @rows = LookupRows("Contacts","ContactID", @contactID)
set @row = Row(@rows, 1)
set @first = Field(@row,"first")

]%%
%%=ProperCase(@first)=%%

I have more lookup examples here on my blog.

3

You're missing an additional step if you're going to use LookupRows().

LookupRows() will retrieve your rowset. Row() will target the row. Field() will retrieve the value in column, w/in that row.

Adding to your code...

...
set @rows = LookupRows("Contacts","FirstName", @first)
set @row = Row(@rows, 1)
Set @first = Field(@row,"FirstNameColumn")
]%%

%%=ProperCase(@first)=%%

However, what you're doing doesn't seem to make much sense. The code is matching first name to first name in order to retrieve first name.

1
  • Thanks! I've tried this but getting an odd behavior. The email validates, but when I try to do a live preview it says it can't generate it... which usually means there's an error... but it validates. Any ideas?
    – Peachy
    Commented May 12, 2016 at 21:43

You must log in to answer this question.

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