1

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

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.

  • 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 May 12 '16 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.