I am using regularly the ClaimRow() function in many of my sends for assigning coupons to my subscribers. As I have to be able to assign more than one coupon to my subscribers from different sends, I have included some extended functionality to the ClaimRow function: basically after claiming one coupon, I delete the coupon from the original data extension and insert the claimed details in a secondary data extension for keep monitoring the coupons being claimed properly. As I am deleting the records from the original data extension I can use ClaimRow later on and assign new coupons to the same subscriber. This functionality is working properly.

Now, I have to assign in one unique email, two different coupons to the same subscriber, so what I am doing is to execute my code twice in a row. The thing is that is not working. It is assigning properly the first coupon, so the first time I call ClaimRow() function is working but after that gets blocked and the Email is being cancelled.

My code is:

   Set @CouponRow = ClaimRow('DEName', 'IsClaimed', 'SubscriberKey', _subscriberkey, 'EmailAddress', emailaddr)
   IF NOT EMPTY(@CouponRow) THEN
   Set @couponCode = Field(@CouponRow, "CouponCode")
   Set @ClaimedDate = Lookup('DEName','ClaimedDate','CouponCode', @couponCode)
   Set @TimeStamp = Lookup('DEName','TimeStamp','CouponCode', @couponCode)
   InsertDE('DEName_Claimed','CouponCode', @couponCode, 'EmailAddress', emailaddr, 'isClaimed','True', 'TimeStamp', @TimeStamp, 'ClaimedDate', @ClaimedDate, 'SubscriberKey', _subscriberkey)
   DeleteDE('DEName','CouponCode', @couponCode)
  • What's your actual code? You have some incomplete stuff, but I don't see where you're executing twice etc...
    – Macca
    Commented Jun 25, 2020 at 15:22

1 Answer 1


I can see, that you are using a very basic set of criteria to identify which row to claim:

Set @CouponRow = ClaimRow('DEName', 'IsClaimed', 'SubscriberKey',
 _subscriberkey, 'EmailAddress', emailaddr)

This will limit the claiming to only one row in Data Extension for each of your subscribers. What you need, is another column, allowing you to distinguish each of the function calls, e.g.:

Set @CouponRow1 = ClaimRow('DEName', 'IsClaimed', 'SubscriberKey',
 _subscriberkey, 'EmailAddress', emailaddr, 'claimNumber',1)
Set @CouponRow2 = ClaimRow('DEName', 'IsClaimed', 'SubscriberKey',
 _subscriberkey, 'EmailAddress', emailaddr, 'claimNumber',2)

When your second function call is executed, it will look for unclaimed row, with a combination of subscriber key, email address and claimNumber. As number 1 is already claimed, and number two is not, it will execute twice, and mark two rows as claimed.

The value of claimNumber should just be null on import. Do keep in mind, that you can't do conditional claiming. I.e. all your coupons in the data extension should be of same type (e.g. free shipping OR 10% off). If your two coupons differ by type, they need to be claimed from two different DEs. The value of claimNumber only serves the purpose of identifying in which context the coupon was claimed.

The example on the documentation page also includes additional values, such as jobId and listId, making it unnecessary to remove claimed rows from your data extension:

SET @CouponRow = ClaimRow('Coupon', 'IsClaimed', 'JobID', JobID,
 'ListID', ListID, 'BatchID', _JobSubscriberBatchID,
 'SubscriberID', SubscriberID)
  • Thanks a lot Lukas for your recommendation. To get your scenario working, I think you also need to prepare and import the coupons setting up also this ClaimNumber values right ? Do you think am I facing some kind of racing or locked conditions ? My code is working well and I can use this code to send and assign differnet coupons to the same subscriber in different sends, but I don't know why, doing that in the same Send twice is not working: ClaimRow() + Insert REcord in Claimed DE + Delete REcord in original DE + ClainRow() + Insert Recordd in Claimed DE + Delte REcord in original DE. Commented Jun 25, 2020 at 15:33
  • @EnriqueDiaz - you don't have to populate it. See my updated answer Commented Jun 25, 2020 at 15:37
  • I understand now what you mean. I will do then in this way. Thanks again Lukas ! So the way this is working is that in your example, after claiming the first coupon, the system will assign value 1 to the ClaimNumber field automatically ? Commented Jun 25, 2020 at 15:41
  • That's correct, @EnriqueDiaz Commented Jun 25, 2020 at 16:03

You must log in to answer this question.

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