Coupons in Salesforce using ClaimRow

699 views Asked by At

I'm trying to add a Promo Code into an email using the ClaimRow method in SalesForce, so that as soon as a user has claimed a code that will be marked in the Data Extension

I've looked online and they all have the same set up which I created.

The Data Extension that is being called is set up like so with the Promo Codes populated:

PromoCode - Data type= Text; Length =100; Primary Key= True, Nullable= none; Default Value = none

IsClaimed - Data type= Boolean; Length =none; Primary Key= false, Nullable= true; Default Value = False}

EmailAddress - Data type= EmailAddress; Length =none; Primary Key= false, Nullable= true; Default Value = none

with the AMPscript being set up as:

%%[

var @em, @couponRow, @couponCode

    set @em = AttributeValue("emailAddr")

    set @couponRow = ClaimRow("UK_£10_Off_£30_Codes_2", "IsClaimed", "EmailAddress", @em)

    if not empty(@couponRow) then

      set @couponCode = Field(@couponRow, "PromoCode")

    else

        RaiseError("No codes available", false)

    endif

]%%

Coupon code: %%=v(@couponCode)=%%

This looks right but it's raising the error of "No codes available". When I remove the If statement the error message is:

Invalid row (parameter 1) passed to Field function. Row is null or empty. Function: Field(@couponRow, "PromoCode")

I've hit a brick wall now and any help would be much appreciated

1

There are 1 answers

0
kurt78 On

This is now working

The issue was that the IsClaimed row didn't populate the default value as "False"