---
schema_version: "1"
id: 69e5f5905f4259967f211ac98eecc5bc3e4aa673c37eb3834e5671eaced7d728
title: ClaimRow()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/data-extension/mc-ampscript-reference-data-extension-claim-row.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-claim-row.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1a1be3558018b9a029d204f192dd975f6dd55b53666026da5bed3c4f30272776
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# ClaimRow()

Returns the first unclaimed row from a data extension. The row that was returned is updated in the data extension to indicate that it has been claimed. Subsequent operations return the next unclaimed row in the data extension. This function is commonly used for managing coupon codes and redemption.

This function is similar to the [ClaimRowValue()](https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-claim-row-value.md) function. However, the `ClaimRowValue()` function can return a fallback value if the data extension doesn’t contain any unclaimed rows, while this function returns an exception if there aren’t any unclaimed rows. Additionally, this function returns an entire row, while the `ClaimRowValue()` function returns a value from the unclaimed row.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

## Syntax

```
ClaimRow(dataExt,
         claimColumn,
         claimantColumn1, claimantValue1,
         [claimantColumn2, claimantValue2 ...])
```

The `ClaimRow()` function has four parameters:

- `dataExt` (string): Required. The data extension that contains the value to return. You must hard-code this value. If you specify an AMPscript variable for this parameter, the function returns an exception.
- `claimColumn` (string): Required. The column that the function uses to track whether a row is claimed. This column must be configured in a specific way in the data extension; see [Data Extension Configuration](#data-extension-configuration) for more information.
- `claimantColumn` (string): Required. The column that the function uses to track the subscriber who claimed the row.
- `claimantValue` (string): Required. The value to enter in the `claimantColumn` column when the function claims a row.

You can populate more than one column in the claimed row by appending additional column names and values to the end of the function.

## Data Extension Configuration

To use this function, your data extension must contain a required (non-nullable) boolean attribute with a default value of `False`. The data extension must also have a column for tracking the entity that claimed a row.

This table shows the fields in a minimal data extension that you can use with this function.

| Attribute Name | Data Type | Required? | Default Value |
| -------------- | --------- | --------- | ------------- |
| CouponCode     | Text      | Yes       |               |
| EmailAddress   | Text      | No        |               |
| IsClaimed      | Boolean   | Yes       | False         |
| ClaimedDate    | Date      | No        |               |

**note:** The ClaimedDate column isn’t strictly required to use this function. If your data extension includes this column, the function automatically inserts a timestamp in the ClaimedDate column when it claims a row. The column must be nullable, have a data type of Date, and have the name "ClaimedDate".

## Usage

This example uses a data extension called "CouponCodes," which contains the data in this table.

| CouponCode | EmailAddress | IsClaimed | ClaimedDate |
| ---------- | ------------ | --------- | ----------- |
| S5MY7BVU   |              | False     |             |
| 40PNCHO2   |              | False     |             |
| 718BZOY0   |              | False     |             |
| 08713TEH   |              | False     |             |
| AM0R1397   |              | False     |             |
| ZFUX4591   |              | False     |             |

To claim a coupon code from this data extension for a subscriber and make that code unavailable to other subscribers, pass the required parameters to the `ClaimRow()` function.

```
%%[
  Var @emailAddress, @couponCodeRow, @couponCode
  Set @emailAddress = AttributeValue("emailAddr")
  Set @couponCodeRow = ClaimRow("CouponCode",
                                /* Column that denotes claim status */
                                "IsClaimed",
                                /* Column to populate when claiming the row */
                                "EmailAddress",
                                /* Value to populate column with when claiming the row */
                                @emailAddress
                                )
  Set @couponCode = Field(@couponCodeRow,"CouponCode")
]%%
<p>Your coupon code is %%=v(@couponCode)=%%</p>
```

The code example outputs the first unclaimed coupon code in the data extension:

```
Your coupon code is S5MY7BVU
```

The function also updates the corresponding row in the data extension to indicate that the coupon has been claimed. The data extension now resembles this example.

| CouponCode | EmailAddress          | IsClaimed | ClaimedDate         |
| ---------- | --------------------- | --------- | ------------------- |
| S5MY7BVU   | sunhi.kim@example.com | True      | 8/5/2023 1:41:32 PM |
| 40PNCHO2   |                       | False     |                     |
| 718BZOY0   |                       | False     |                     |
| 08713TEH   |                       | False     |                     |
| AM0R1397   |                       | False     |                     |
| ZFUX4591   |                       | False     |                     |

## See Also

- [ClaimRowValue()](https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-claim-row-value.md)
