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:
- using variable for ampscript Claimrow function
- Coupon code automated in journey: claimrow or lookuporderedrows + updateDE
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)
endif
]%%
So as I said this is not working for me.
Can someone help me a bit by fine tuning this code?
Thanks a lot,
Alex