Day 13 – Offer limited discount codes from a different Data Extension


To provide a limited amount of discount codes to customers, once discount codes run out offer a smaller discount.


SET @email = Email
SET @defaultcode = "WELCOME15"
SET @promocode = ClaimRowValue("AMPscript - Day 13 Promo_Codes", "PromoCode", "IsClaimed", @defaultcode, "Email", @email)



ClaimRowValue(name of data extension for claim or retrieve action, name of column in data extension from which to retrieve the return value, name of column in data extension that indicates a claimed or unclaimed row, default value to use in case the function fails to claim a row – optional, name of the data extension key column, value of data extension key column) retrieves the promo code from a different Data Extension, and provides an option for having a default value as a fallback. As the given Data Extension doesn’t have the “IsClaimed” and “Email” fields, I added extra fields to the “AMPscript – Day 13 Promo_Codes” Data Extension.