0

I'm trying to create a personalized mailer where recommended products will be pitched to each customer.

I'm getting error - An unrecognized expression appears in a script block. Script Expression: Testing_database_lead_journey:AESL_Class_LK__c

Below is the ampscript code I'm using -

code for setting variables

%%[

var @currentClassCode
var @stream
var @courseDetailsRows
var @courseDetailsRow1
var @courseDetailsRow2
var @title1
var @title2
var @Line1_1
var @Line1_2
var @Line2_1
var @Line2_2
var @Line3_1
var @Line3_2
var @Link1
var @Link2
var @Number1_1
var @Number1_2
var @Number2_1
var @Number2_2

set @currentClassCode = Testing_database_lead_journey:AESL_Class_LK__c 
set @stream = Testing_database_lead_journey:AESL_Stream__c

set @courseDetailsRows = LookupOrderedRows('DigitalJourneyCourseDetails', 2, 'Priority ASC', 'ClassCode', @currentClassCode, 'Stream', @stream, 'Product', 'ICON')

if RowCount(@courseDetailsRows) > 0 then

    set @courseDetailsRow1 = Row(@courseDetailsRows, 1)

    set @Description1 = Field(@courseDetailsRow1, 'Description')
    set @title1 = Field(@courseDetailsRow1, 'Title')
    set @Line1_1 = Field(@courseDetailsRow1, 'Line1')
    set @Line2_1 = Field(@courseDetailsRow1, 'Line2')
    set @Line3_1 = Field(@courseDetailsRow1, 'Line3')
    set @Link1 = Field(@courseDetailsRow1, 'Link')
    set @Number1_1 = Field(@courseDetailsRow1, 'TollFreeNumber1')
    set @Number1_1 = Field(@courseDetailsRow1, 'TollFreeNumber2')

    if RowCount(@courseDetailsRows) > 1 then
        set @courseDetailsRow2 = Row(@courseDetailsRows, 2)
        set @Description2 = Field(@courseDetailsRow2, 'Description')
        set @title2 = Field(@courseDetailsRow2, 'Title')
        set @Line1_2 = Field(@courseDetailsRow2, 'Line1')
        set @Line2_2 = Field(@courseDetailsRow2, 'Line2')
        set @Line3_2 = Field(@courseDetailsRow2, 'Line3')
        set @Link2 = Field(@courseDetailsRow2, 'Link')
        set @Number2_1 = Field(@courseDetailsRow2, 'TollFreeNumber1')
        set @Number2_1 = Field(@courseDetailsRow2, 'TollFreeNumber2')
    endif

endif
]%%

Code for printing out recommended products in email

%%[ if not Empty(@title1) then ]%%Course name:%%= v(@title1) =%%%%[ endif ]%%
%%[ if not Empty(@Line1_1) then ]%%Course details:%%= v(@Line1_1) =%%%%[ endif ]%%
%%[ if not Empty(@Line2_1) then ]%%%%= v(@Line2_1) =%%%%[ endif ]%%
%%[ if not Empty(@Line3_1) then ]%%%%= v(@Line3_1) =%%%%[ endif ]%%

Please suggest how do I fix this.

1
  • Are Testing_database_lead_journey:AESL_Class_LK__c and Testing_database_lead_journey:AESL_Stream__c columns in your send context? Commented Jan 9, 2019 at 12:59

3 Answers 3

2

I tried some hit & trials and got the answer. Actually there is error in ampscript syntax.

"Testing_database_lead_journey:AESL_Class_LK__c" this type of syntax should be used for synchronised data extension while I was applying the same code on manually created data extension.

Once I removed table name & ":", i.e. use only "AESL_Class_LK__c", it worked.

0

Assuming that AESL_Class_LK__c and AESL_Stream__c are columns in your Testing_database_lead_journey audience, then you need to retrieve the values using AttributeValue:

You can also simplify it by using a for-loop:

%%[

var @currentClassCode
var @stream
var @rows

set @currentClassCode = AttributeValue("AESL_Class_LK__c")
set @stream = AttributeValue("AESL_Stream__c")

if not empty(@currentClassCode) and not empty(@stream) then

    set @rows = LookupOrderedRows('DigitalJourneyCourseDetails', 2, 'Priority ASC', 'ClassCode', @currentClassCode, 'Stream', @stream, 'Product', 'ICON')

    var @rowCount 
    set @rowCount = RowCount(@rows) 

    if @rowCount > 0 then

        for @i = 1 to @rowCount do

            var @row
            var @Description
            var @title
            var @Line1
            var @Line2
            var @Line3
            var @Link
            var @Number1
            var @Number1

            set @row = Row(@rows, @i)
            set @Description = Field(@row, 'Description')
            set @title = Field(@row, 'Title')
            set @Line1 = Field(@row, 'Line1')
            set @Line2 = Field(@row, 'Line2')
            set @Line3 = Field(@row, 'Line3')
            set @Link = Field(@row, 'Link')
            set @Number1 = Field(@row, 'TollFreeNumber1')
            set @Number1 = Field(@row, 'TollFreeNumber2')

            Write(concat("<br><br>i: ", @i))
            Write(concat("<br>Description: ", @Description))
            Write(concat("<br>title: ", @title))
            Write(concat("<br>Line1: ", @Line1))
            Write(concat("<br>Line2: ", @Line2))
            Write(concat("<br>Line3: ", @Line3))
            Write(concat("<br>Link: ", @Link))
            Write(concat("<br>Number1: ", @Number1))
            Write(concat("<br>Number1: ", @Number1))

        next @i

    else 

        Write(concat("<br>No rows found"))

    endif
else

    Write(concat("<br>Missing values for lookup"))

endif
]%%
0

You forgot to put the name of your Journey Data attributes between brackets

set @currentClassCode = [Testing_database_lead_journey:AESL_Class_LK__c] 
set @stream = [Testing_database_lead_journey:AESL_Stream__c]
3
  • Pretty sure they're not meant to be literal strings for his lookup. Commented Jan 9, 2019 at 12:59
  • Do you think they're context variables and they should be declared between brackets ?
    – zeljazouli
    Commented Jan 9, 2019 at 13:05
  • It depends on the send context of the email. I'm not a fan of referencing unchecked contextual variables, which is why I always wrap those in AttributeValue(). It gives you an opportunity to check make sure they have a value. Commented Jan 9, 2019 at 17:43

You must log in to answer this question.

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