I'm new to SFMC and AMPScript. I want to create an email that starts with the name of the employee who receives it, using the Lookup() function to return their name.

My code:

%%[ SET @subKey = AttributeValue("_subscriberkey") SET @name = Lookup("Employees", "name", "employeeId", @subKey) ]%% %%=v(@name)=%%

But it doesn't work. The _subscriberkey matches with the primary key of the data extension "Employees". The PK is "employeeId".

When I simply test with:

%%[ SET @subKey = AttributeValue("_subscriberkey") ]%% %%=v(@subKey)=%%

it works!

My problem is when I use the lookup:

enter image description here

I need to return the name of the employee. How can I do that? Please, I need your help :)

  • Is there a name field in the Employees data extension? Commented May 21 at 17:55
  • Yes, Employee data extension has a "name" field which I use in the Lookup: Lookup("Employees", "name", "employeeId", @subKey) Commented May 22 at 10:16

1 Answer 1


From the screenshot of your error message it seems there is some unwanted html added inside your AMPscript.

Try using a code snippet block for the AMPscript or make sure you edit your AMPscript in the text version of the content block you are using.

Ref: https://help.salesforce.com/s/articleView?id=sf.mc_ceb_create_code_snippet.htm&language=en_US&type=5

You must log in to answer this question.

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