0

I plan to use many data extensions for voucher code
so I created a reference data extension and capture the data extension name from there

SET @getde = Lookup ("v1-reference", "DE", "date_code", @fullcode)

and then I claim the row

 SET @voucherrow = ClaimRow(@getde, "IsClaimed", "email", email)

but this will create an error
I've tried to put the data extension name directly in the function and it works:

SET @voucherrow = ClaimRow("voucher_pool", "IsClaimed", "email", email)

Is there any of you know how to achieve this, a workaround maybe. Thanks

here is the error:

2
  • Can you post the error? Also are you sure that @getde == "voucher_pool"?
    – Jon Sakas
    Mar 18, 2014 at 17:18
  • I uploaded the error message. I am sure that @getde == "voucher_pool" I did test and retest
    – Faris
    Mar 19, 2014 at 7:33

3 Answers 3

2

I made it work this way:

    %%[
    SET @SubscriberKey = 'My_SubscriberKey'
    SET @de_name = 'My_DE_Name'
    TreatAsContent(Concat("%%[ SET @CouponRow = ClaimRow('", @de_name, "', 'IsClaimed', 'JobID', JobID, 'ListID', ListID, 'BatchID', _JobSubscriberBatchID, 'SubscriberKey', '", @SubscriberKey, "') ]%%"))

    IF NOT EMPTY(@CouponRow) THEN
    ]%%
    Your Coupon Code is %%=Field(@CouponRow,'CouponCode')=%%
    %%[ ENDIF ]%%

TreatAsContent will execute the code string and set the @CouponRow for later use.

I sometimes had an issue with the code erroring but I fixed it by closing and re-opening the AMPScript block tags around the TreatAsContent this way:

    ...
    ]%%
    %%[
    TreatAsContent(Concat("%%[ SET @CouponRow = ClaimRow('", @de_name, "', 'IsClaimed', 'JobID', JobID, 'ListID', ListID, 'BatchID', _JobSubscriberBatchID, 'SubscriberKey', '", @SubscriberKey, "') ]%%"))
    ]%%
    %%[
    ...
1

The ClaimRow() and ClaimRowValue() functions do not accept variables for the Data Extension name, only literals.

1
  • Really horrible as to why it doesn't! Little hang-ups like that with AMPScript continue to cause such useless delays.
    – ElHaix
    Oct 31, 2019 at 15:58
0

Did you mean to have email as the value in ClaimRow(@getde, "IsClaimed", "email", email)? I would have expected a variable name like @email, or a personalization string like emailaddr.

3
  • No. I mean to have a variable for data extension name used by the claimrow function
    – Faris
    Mar 19, 2014 at 7:25
  • OK, I was misunderstanding. A grasping at straws kind of answer: Have you tried declaring your variables using the VAR keyword at the beginning of your code? 99% of the time it doesn't matter, but I've a couple of issues where it does.
    – Timothy
    Mar 19, 2014 at 18:54
  • yes I did make sure that the var was there
    – Faris
    Mar 20, 2014 at 7:59

You must log in to answer this question.

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