0

I want to output some data and using 'Output' and 'Lookup' functions.

If my DE fields looks like this:

Name           Data Type.      Length. Primary Key. Nullable. Default Value
FIRST NAME     Text            50
LAST NAME      Text            50
EMAIL.         EmailAddress.   254.     x

What is the correct AmpScript to output someone's first name?

My AmpScript currently looks like this. I have a feeling my 4th argument is incorrect b/c I"m not sure what is the "Value that identifies the row to retrieve" according to docs.

%%[

var @firstName
set @firstName = Lookup("DE__Test", "FIRST NAME", "EMAIL", EMAIL)

Output(Concat("First Name: ", @firstName))

]%%
1
  • Are you getting an error message? Syntax is correct assuming the name of the data extensions is right. Jul 9 at 2:52
2

The fourth argument is like the field name for the first condition of a where-clause in a SQL statement. You could write your lookup in pseudocode like this:

Retrieve FIRST NAME from DE__Test where EMAIL = EMAIL

Also, you don't need to use a lookup if DE__Test is the sending data extension.

You can reference the send context column names directly or assign them to variables:

%%[

var @firstName
set @firstName = AttributeValue("First Name")

output(concat("<br>Hi, ", @firstName))

]%%
2
  • One more thing to this answer, OP should set 4th argument - @Email in order to make his Lookup function work (as long as field names are correct), it could be done the same way as shown above with the AttributeValue function.
    – Niko
    Jul 9 at 7:37
  • 1
    Agreed, but it's not necessary if the sending DE has a column named EMAIL. Jul 9 at 11:41

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.