Let us know so we can improve!
Handlebars Helper Function: claimRow
Returns the first unclaimed row from a marketing object and updates that row to indicate that it’s claimed. Use this helper to distribute values such as coupon codes.
Availability
This helper is available in the Winter ’27 release of Marketing Cloud Next.
Syntax
1{{claimRow object=MARKETING_OBJECT_NAME
2 claimCol=COLUMN CLAIMANT_DATA="CLAIMANT_DATA_VALUE" ...}}Parameters
| Parameter | Type | Description |
|---|---|---|
object | String | Required. The name of the marketing object that contains the rows to claim. Specify as a named parameter. |
claimCol | String | Required. The column that tracks whether a row is claimed. Specify as a named parameter with the value equal to the column name. |
CLAIMANT_DATA | String | Required. The column to populate with data about the user claiming the row. Specify the name of the column as a named parameter, and set the value of the parameter to the value to populate in the claim table. |
You can update multiple columns in the marketing object by appending more CLAIMANT_DATA="CLAIMANT_DATA_VALUE" pairs to the function.
Return Value
The function returns the claimed row, or throws an exception if there aren’t any unclaimed rows.
Usage Example
This example claims a coupon code from the CouponCodes marketing object for a subscriber and marks that code unavailable to other subscribers. It returns the value from the CouponCode column in the marketing object. Before the helper runs, the marketing object contains these rows.
| CouponCode | EmailAddress | IsClaimed |
|---|---|---|
| S5MY7BVU | false | |
| 40PNCHO2 | false | |
| 718BZOY0 | false |
1{{#set emailAddress}}sunhi.kim@example.com{{/set}}
2
3{{#with (claimRow object="CouponCodes" claimCol="IsClaimed" EmailAddress=emailAddress)}}
4 Your coupon code is {{CouponCode}}
5{{/with}}This example produces this output:
1Your coupon code is S5MY7BVUThe helper updates the CouponCodes marketing object. After this operation, the marketing object contains this data.
| CouponCode | EmailAddress | IsClaimed |
|---|---|---|
| S5MY7BVU | sunhi.kim@example.com | true |
| 40PNCHO2 | false | |
| 718BZOY0 | false |
Providing a Fallback Value
If there aren’t any unclaimed rows in the marketing object, the function throws an exception. For this reason, it’s helpful to combine this function with fallback. This example shows how to combine these functions.
1{{#set emailAddress}}sunhi.kim@example.com{{/set}}
2
3{{#with (claimRow object="CouponCodes" claimCol="IsClaimed" EmailAddress=emailAddress)}}
4 Your coupon code is {{fallback CouponCode "10OFF100"}}
5{{/with}}If there are no unclaimed coupon codes remaining, the value of CouponCode is null. In this situation, the function returns the fallback code, “10OFF100”.
See Also
Let us know so we can improve!