0

I am trying to use the LookupOrderedRows function. I've followed the setup according to the AMPscript guide (https://ampscript.guide/lookuporderedrows/) but Marketing Cloud email preview is throwing the following error:

The subscriber preview failed to generate. Review the details, correct all issues, and try again.
A variable name is not a valid because contains illegal characters. Variable names must begin with the @ symbol followed by one or more letters, numbers, or underscores. Variable Name: <

Here is the AMPscript I'm working with:

%%[
var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i,

set @lookupValue = AttributeValue("Opportunity__c") /* value from attribute or DE column in send context */
set @lookupValue2 = '1' /* value from attribute or DE column in send context */
set @MonthlyRent__c = AttributeValue("MonthlyRent__c")
set @numRowsToReturn = 15 /* 0 means all, max 2000 */
set @rows = LookupOrderedRows("DE_Multi_Request_Lookup_Table",@numRowsToReturn,"Status__c ASC, Apartment_Code__c, Moveoutdate__c, Moveindate__c, CurrencyIsoCode, City__c, Cover_picture__c, Postal_Code__c, Street__c, Homelike_ID__c, MonthlyRent__c,","Opportunity__c", @lookupValue)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @Status__c, @Apartment_Code__c, @Moveoutdate__c, @Moveindate__c, @CurrencyIsoCode, @City__c, @Homelike_ID__c, @Cover_picture__c, @Postal_Code__c, @Street__c, @MonthlyRent__c, @Opportunity__c
    set @row = row(@rows,@i) /* get row based on counter */
    set @Status__c = field(@row,"Status__c")
    set @Apartment_Code__c = field(@row,"Apartment_Code__c")
    set @Moveindate__c = field(@row,"Moveindate__c")
    set @Moveoutdate__c = field(@row,"Moveoutdate__c")
    set @CurrencyIsoCode = field(@row,"CurrencyIsoCode")
    set @City__c = field(@row,"City__c")
    set @Postal_Code__c = field(@row,"Postal_Code__c")
    set @Street__c = field(@row,"Street__c")
    set @Homelike_ID__c = field(@row,"Homelike_ID__c")
    set @Cover_picture__c = field(@row,"Cover_picture__c") 
    set @MonthlyRent__c = field(@row,"MonthlyRent__c")
    set @Opportunity__c = field(@row,"Opportunity__c")

   ]%%

%%=v(@Street__c)=%%, %%=v(@Postal_Code__c)=%%, %%=v(@City__c)=%% | %%=v(@Apartment_Code__c)=%% | %%=v(@MonthlyRent__c)=%% Avg. Month | %%=v(@Status__c)=%%
%%[next @i]%%%%[ELSE]%%%%=ContentBlockbyID("365429")=%%%%[ENDIF]%%

Is there anything obvious that I've missed here?

2 Answers 2

4

Try to get rid of the comma after MonthlyRent__c in the @rows variable:

set @rows = LookupOrderedRows("DE_Multi_Request_Lookup_Table",@numRowsToReturn,"Status__c ASC, Apartment_Code__c, Moveoutdate__c, Moveindate__c, CurrencyIsoCode, City__c, Cover_picture__c, Postal_Code__c, Street__c, Homelike_ID__c, MonthlyRent__c","Opportunity__c", @lookupValue)
1
  • 1
    Thank you. That was a good suggestion. Also realised the editor was putting in unwanted HTML such as <br>, so I removed this and the HTML loads, but no content from the lookup yet :( Commented Oct 13, 2022 at 17:18
0

After some more digging and thanks to @zuzannamj, I discovered:

  1. Needed to remove the comma after MonthlyRent__c
  2. Needed to paste the AMPscript in the HTML editor to avoid the automatic input of breaks
    in the code
  3. Needed to ensure the Data Extension I was previewing had the correct lookup value.

Now I have the data, it's time to format it!

1

You must log in to answer this question.

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