0

I've been trying to print the product rows from a DE in a digital receipt email. Everything works fine unless I want to declare the variables. So the code underneath works perfectly if I remove the var @lookupValue. When I try to initialize the vars @productName, @productPrice in the for-loop, I get the same issue.

Full code:

%%[
var @lookupValue
set @lookupValue = FirstName 

set @numRowsToReturn = 0 
set @rows = LookupOrderedRows("TESTDE",@numRowsToReturn,"ProductPrice asc","FirstName", @lookupValue)

set @rowCount = rowcount(@rows)

if @rowCount > 0 then 

  for @i = 1 to @rowCount do 
    set @row = row(@rows,@i) 
    set @productName = field(@row,"ProductName") 
    set @productPrice = field(@row,"ProductPrice") 

]%%

Product row %%=v(@i)=%%, product name is %%=v(@productName)=%%, product price is %%=v(@productPrice)=%%

%%[ next @i ]%%
%%[ endif ]%%

These are the error messages I get:

Error messages

If anyone has any experience, all help is appreciated.

3
  • 2
    For information, you don't need to declare a variable in AMPScript. You can directly SET it to whatever you want. Commented Jun 13, 2019 at 16:05
  • Tested it inside my own environment inside an html block and the code is working Commented Jun 13, 2019 at 18:21
  • Same thing on my side. It's working fine Commented Jun 13, 2019 at 19:54

1 Answer 1

2

I believe you wrote this script inside a text area and not inside HTML or codeblocks. Thats why everything is transformed/encoded into html. For example your newlines are now a <br> and your " now may even be &quot; Because you actually do not have a <br> between your code and i believe it should be working.

Atleast the code works for me when i changed it to my environment (other identifier and dataextensions)

1
  • I agree looking at the code and the error it appears there is some character after var @lookup two options take it to notepad or just remove it
    – EazyE
    Commented Jun 13, 2019 at 19:16

You must log in to answer this question.

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