Handlebars Helper Function: assignCoupon

Claims a coupon row from a marketing object for the current recipient. Use this helper to assign a coupon code from a coupon list.

Availability 

This helper is available in the Winter ’27 release of Marketing Cloud Next.

Syntax 

1{{assignCoupon list="CouponCodes"}}

Parameters 

ParameterTypeDescription
listStringRequired. The name of the marketing object that contains the coupon rows.

Return Value 

The function returns the claimed coupon row as an object. Use the get helper to retrieve values from the returned row.

For a coupon list that isn’t configured to always assign a new coupon, the helper returns the coupon previously assigned to the same recipient.

If no coupon is available, the coupon list isn’t valid, or the recipient doesn’t have an individual ID, the function throws an exception. You can use the fallback helper to handle an unavailable coupon.

Usage Examples 

This example assigns a coupon and renders the value in the CouponCode field.

1{{#with (assignCoupon list="CouponCodes")}}
2  Your coupon code is {{get this "CouponCode"}}.
3{{/with}}

Providing a Fallback Value 

This example renders a fallback message when a coupon isn’t available.

1{{fallback (get (assignCoupon list="CouponCodes") "CouponCode") "No coupon available"}}

See Also