2

The Error

Error 1: Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", "StoreCouponCode", "Customer_No", @numberCustomer) MemberID: 7221103 JobID: 0 The Data Extension field name for a ClaimRow function call is invalid. A field of this name does not exist. Function Call: ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", "StoreCouponCode", "Customer_No", @numberCustomer) Data Extension Name: MatthewDataExtension Field Name: isClaimed Parameter Name: BoolClaimedColumnName Parameter Ordinal: 2
Invalid Content:
set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", "StoreCouponCode", "Customer_No", @numberCustomer)

The ampscript

%%[
    var @numberCustomer
          set @numberCustomer = [Customer_No]

    var @couponDataExtensionRow
      set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", "StoreCouponCode", "Customer_No", @numberCustomer)

    var @codeOnline
    var @barCode

    IF NOT EMPTY(@couponDataExtensionRow) THEN
          set @codeOnline = FIELD(@couponDataExtensionRow,"WebPromoCode")
          set @barCode = FIELD(@couponDataExtensionRow, "StoreCouponCode")
    ENDIF
]%%

The Data Extension

enter image description here

The Actual Data

enter image description here

Research and other items

I've checked this question, but my data extension doesn't have spaces in the name. I've also checked the documentation for ClaimRow, and I thought I had it set up correctly. I'm seeing this error when I try to validate my email. The invalid content appears to be for the isClaimed content. Am I right in thinking that, and is false an invalid option there? My apologies if it's something obvious, it's my first day with ampscript and Salesforce.

Updated ampscript

I updated the script as suggested, but I'm still getting the same errors:

%%[
    var @numberCustomer
          set @numberCustomer = AttributeValue("Customer_No")

    var @WebPromoCode
          set @WebPromoCode = AttributeValue("WebPromoCode")

    var @StoreCouponCode
          set @StoreCouponCode = AttributeValue("StoreCouponCode")

    var @couponDataExtensionRow
      set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "IsClaimed", "WebPromoCode", @WebPromoCode, "StoreCouponCode", @StoreCouponCode, "Customer_No", @numberCustomer)

    var @onlineCode
    var @barcode

    IF NOT EMPTY(@couponDataExtensionRow) THEN
          set @onlineCode = FIELD(@couponDataExtensionRow,"WebPromoCode")
          set @barcode = FIELD(@couponDataExtensionRow,"StoreCouponCode")
    ENDIF
]%%

The isClaimed column was changed in the DE to IsClaimed.

I've also tried a smaller ClaimRow():

var @couponDataExtensionRow
      set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "IsClaimed", "Customer_No", @numberCustomer)

Which at least gives me a different error:

Error 1: Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: ClaimRow("MatthewDataExtension", "IsClaimed", "Customer_No", @numberCustomer) MemberID: 7221103 JobID: 0 The Data Extension field name for a ClaimRow function call is invalid. A field of this name does not exist. Function Call: ClaimRow("MatthewDataExtension", "IsClaimed", "Customer_No", @numberCustomer) Data Extension Name: MatthewDataExtension Field Name: IsClaimed Parameter Name: BoolClaimedColumnName Parameter Ordinal: 2
Invalid Content:
set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "IsClaimed", "Customer_No", @numberCustomer)

4
  • I'd delete your coupon data extension and recreate it with a primary key. Jan 13, 2016 at 23:35
  • You think adding it after the fact might be causing issues? I'll do that first thing in the morning and post the result. Jan 14, 2016 at 3:55
  • 1
    @AdamSpriggs Not sure how that fixed it, but re-creating the DE and the tips below got it. Answer accepted, and thanks for the help! Jan 14, 2016 at 16:13
  • 1
    Sweet. I saw your MID (7221103) and took a peek at the server error log and noticed some PK errors. Occasionally DE primary key changes will error out without any indication in the UI. Awesome, I know. Jan 14, 2016 at 16:56

2 Answers 2

2

First, I'd suggest setting a primary key on your MatthewDataExtension Data Extension, since the ClaimRow() function is doing an update.

Also, every pair of ClaimRow() parameters after the 2nd needs to be the variable name and then the variable value -- in order to retrieve the proper row. So if you're going to update WebPromoCode and StoreCouponCode, your function would be this:

%%[

var @numberCustomer
var @WebPromoCode
var @StoreCouponCode
set @numberCustomer = AttributeValue("Customer_No")
set @WebPromoCode = AttributeValue("WebPromoCode")
set @StoreCouponCode = AttributeValue("StoreCouponCode")

set @couponDataExtensionRow = ClaimRow("MatthewDataExtension", "isClaimed", "WebPromoCode", @WebPromoCode, "StoreCouponCode", @StoreCouponCode , "Customer_No", @numberCustomer)

/* Snip */ 

]%%

If it helps, here's my go-to coupon claiming AMPScript:

%%[

var @couponRow, @couponCode, @rows, @row, @emailaddr

set @emailaddr = AttributeValue("emailaddr")

set @rows = LookupRows("couponCodes","EmailAddress",@emailaddr)

if rowcount(@rows) > 0 then
  set @row = Row(@rows,1)
  set @couponCode= field(@row,"couponCode")
else

    if _messagecontext == "PREVIEW" then
           set @couponCode = "XX TEST XX"
    else

      set @couponRow = ClaimRow("couponCodes","IsClaimed","EmailAddress",emailaddr) 

          if empty(@couponRow) then
             /* You can do other error handling here if you want.*/
             /* This aborts the send */
             raiseError("no more coupons available")
          else 
             set @couponCode= field(@couponRow,"couponCode") 
          endif

    endif 

endif

]%%

Here's your coupon code: %%=v(@couponCode)=%%

There are a few more details about the Data Extension on in my blog post on the subject.

2
  • That helps. I set the key as recommended. What exactly does the AttributeValue("...") do when declaring and setting the variables? Thanks for looking into this btw! Jan 13, 2016 at 22:42
  • 1
    AttributeValue() will return an empty string if the Profile Attribute or sending Data Extension column doesn't exist. If you don't use it and the attribute doesn't exist, your email will blow up. Jan 13, 2016 at 22:46
1

The problem was exactly what the error was telling you the field does not exist in your DE.

Field name in your screenshot of the DE "IsCaimed", Lookup field - IsClaimed

If you just changed the field name, the script would've run. Assume that when you recreated, the field name was spelled correctly. :)

You must log in to answer this question.

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