Here is the requirement - A customer purchases 2 assets, we should be sending two different coupon codes to the same subscriber.

Based on the requirement, we have changed the code (Query) to assign multiple coupons to a Subscriber based on the Asset (ID).

we are using live coupons in the email. During the send time, it is picking only one(Same) Coupon code in both the emails.

with this, duplicate coupon codes are sent to customer though different coupon codes are assigned in the CouponCodes Data Extension.

Ideally it should be picking different coupons assigned to the same subscriber from the coupon code DataExtension.

We are trying to use claimrow() functionality to achieve this. claimed row returns a row that is claimed.

Is there any functionality to display unclaimed row(Couponcode).

Please suggest how to move further

var @coupon, @couponcode
set @subkey = _subscriberkey

set @Rows = LOOKUPORDEREDROWS('Master_Data_Extention_Optin',1,'claimed DESC','Contact_ID',@subkey,'claimed','No')
Set @rowCount1 = RowCount(@Rows)

IF @rowCount1 > 0 then

    set @Rs1 = Row(@Rows,1)
    set @AssetId = Field(@Rs1,'Asset_ID')
    set @claim_row =  ClaimRow('CouponCode_Smartphone','IsClaimed','SubscriberKey',@subkey,'Asset ID','@AssetId')

    IF EMPTY(@claim_row) THEN
        set @coupon = 'error'
        set @couponcode = FIELD(@claim_row,'CouponCode')


couponcode: %%=v(@couponcode)=%%

AssetId: %%=v(@AssetId)=%%

closed as off-topic by Adam Spriggs, Eric, Santanu Boral, Ratan Paul, Mohith Shrivastava Mar 4 '17 at 17:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Adam Spriggs, Eric, Santanu Boral, Ratan Paul, Mohith Shrivastava
If this question can be reworded to fit the rules in the help center, please edit the question.


It sounds like you need to claim a unique coupon per email address AND Asset (ID).

You should add an Asset (ID) column to your CouponCodes data extension and modify your ClaimRow() function to match based on email address AND Asset ID.

Here's a code snippet to illustrate what I mean.

SET @CouponRow = ClaimRow("CouponCodes", "IsClaimed", "EmailAddress", EmailAddr, "Asset_ID", @Asset_ID ) 

NOTE: The code snippet assumes the purchased Asset (ID) is include in your sending audience and is assigned to the @Asset_ID variable prior to calling the ClaimRow() function.

  • Thanks for the guidance David... we are working based on your inputs... will keep you posted. Thanks again!! – Susmitha SFMC Email spl Mar 6 '17 at 7:17
  • Hi David...I have added the code that we are using. we have modified it as u suggested... Email is sent thrice to the subscriber but UpdateDE executed only once. In the send DE Claimed column is only updated for one row. – Susmitha SFMC Email spl Mar 6 '17 at 13:44
  • Does your sending DE contain a column for Asset_ID? Does the email address appear twice in the sending DE? Also, make sure 'De-Duplicate by Email Address' is set to 'No' in your UI Send. – David Devoy Mar 6 '17 at 16:12
  • Yes David All the coulums and setting are good. If we are sending emails to 3 different customers then the code executes and assigning couponcode and also updating Claim. but, If we are sending 3 emails to the same customer(means Same SubscriberId) then the code is executing only once. Deduplication is set to No. please let us know , Is there any setting for this. How do we over come. – Susmitha SFMC Email spl Mar 8 '17 at 12:34
  • I would recommend posting a new questions. I'm not following the need to preform both a ClaimRow() and an UpsertDE() – David Devoy Mar 9 '17 at 14:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.