On the community I have found some information about how to work around the limitation of "hard coded" data extension name in the ClaimRow function.

As reminder, when claiming a row, the rule says that: @CouponRow = ClaimRow("CouponDE","IsClaimed","ContactId",@ContactId) is the way to go. Replacing the parameter "CouponDE" by a variable is not suppose to work.

So as stated above, I found some info on how to work around this limitation. Here are the links:

Now my issue is: I'm trying to work around this limitation as well but can't manage to get this work around in place for my use case. Preview & Test keeps on telling me that the variable @CouponDE is not an existing data extension name. So not sure if the issue is with the work around itself or the way I use the TreatAsContent.

Because when I just use a function I know will not work like: @CouponRow = ClaimRow(@CouponDE,"IsClaimed","ContactId",@ContactId), the error message is different: there it clearly says that the Parameter 1 can not be a variable. Not that he can't find the data extension name.

I can see you all coming: yes, a DE with this specific name exists :-)

Here is my code, simplified at most in order to debug it (no success unfortunately, hence my post here):

 var @CampId, @CampName, @ContactId

  set @CampId = __AdditionalEmailAttribute1
  set @CampName = Lookup("Campaign_Salesforce","Name","Id",@CampId)
  set @ContactId = "11111"

set @CouponDE = CONCAT("Coupon_", @CampId)
set @couponRow = TreatAsContent(Concat("%%[ SET @CouponRow = ClaimRow('", @CouponDE, "', 'IsClaimed', 'ContactId', '", @ContactId, "') ]%%"))

    if not empty(@couponRow) then 
    set @CouponCode = Field(@couponRow,"Coupon_Code")
    else RaiseError("No coupon available for this Contact", true)

So as I said this is not working for me.

Can someone help me a bit by fine tuning this code?

Thanks a lot,


1 Answer 1


You'll need to split the double-percent notations in your TreatAsContent line -- otherwise, the parser will try to evaluate it.

Date/time: %%=format(now(1),"yyyyMMddhhmmss")=%%


/* set @couponRow = ClaimRow("CouponCodes", 'IsClaimed', 'emailAddress', emailaddr) */

set @CouponDE = "CouponCodes"
TreatAsContent(Concat("%","%[ SET @couponRow = ClaimRow('", @CouponDE, "', 'IsClaimed', 'emailAddress', '", emailaddr, "') ]%","%"))

if not empty(@couponRow) then

  set @CouponCode = Field(@couponRow,"CouponCode")


 RaiseError("No coupons available", true)



CouponCode: %%=v(@CouponCode)=%%



Also credit @Seb for this previous answer here.

  • This is working as you describe it Adam! Thank you for your input, it is much much helpful :-) Jul 7, 2020 at 8:20

You must log in to answer this question.

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