{"id":31442,"date":"2018-04-21T15:47:46","date_gmt":"2018-04-21T15:47:46","guid":{"rendered":"https:\/\/ampscript.guide\/claimrowvalue\/"},"modified":"2021-08-06T12:30:49","modified_gmt":"2021-08-06T12:30:49","slug":"claimrowvalue","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/claimrowvalue\/","title":{"rendered":"ClaimRowValue"},"content":{"rendered":"<h2>ClaimRowValue<\/h2>\n<p>Like the <a href=\"\/claimrow\">ClaimRow<\/a> function, ClaimRowValue returns a single row from a Data Extension and reserves the values to prevent them from being used by another operation.  If a row is found and is unclaimed, the designated claimed column is set to <code>true<\/code> and data from that row is returned.  Unlike <a href=\"\/claimrow\">ClaimRow<\/a>, if no unclaimed rows are available in the Data Extension, this function will return the value specified in the fourth parameter.  Claimed rows can be used again if the designated claimed column changes back to <code>false<\/code>.<\/p>\n<p>Generally speaking, you might choose to use the ClaimRowValue function over the <a href=\"\/claimrow\">ClaimRow<\/a> function when you have a default value that can be presented to your Subscribers.<\/p>\n<p>To utilize the ClaimRowValue function, you will need a Data Extension with some specific characteristics. At a minimum, your Data Extension must include the following:<\/p>\n<ol>\n<li>a Boolean column that indicates claimed status, where <code>true<\/code> is claimed and <code>false<\/code> is unclaimed<\/li>\n<li>a nullable column that represents the object or recipient claiming the row.<\/li>\n<\/ol>\n<h3>Arguments<\/h3>\n<p><code>ClaimRowValue(1,2,3,4,5,6,[7a,7b]...)<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">Ordinal<\/th>\n<th style=\"text-align: left;\">Type<\/th>\n<th style=\"text-align: left;\">Required<\/th>\n<th style=\"text-align: left;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">1<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">Data Extension from which to retrieve rows<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">Name of the column from which to retrieve the value<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">3<\/td>\n<td style=\"text-align: left;\">Boolean<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">Name of the column that identifies a row as claimed<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">4<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">Default value to use if there are no available rows to claim<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">5<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">Name of the Data Extension column to populate<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">6<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">Value of the Data Extension column to populate<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">7a<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">Additional name of the Data Extension column to populate (see note)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">7b<\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\">Additional value of the Data Extension column to populate (see note)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>NOTE: Additional pairs of columns and values can be appended as arguments.<\/p>\n<p>NOTE: The Data Extension name in the ClaimRowValue function cannot be an AMPscript variable.<\/p>\n<p>NOTE: By default, this function does not support primary keys like the other update and upsert Data Extension functions.  Additional name\/value pairs of arguments are only for recording additional information at the time the row is claimed, not for retrieving coupons using additional values.  Marketing Cloud Support may be able to alter this default behavior by adding explicit indexes to your coupon data extension, per <a href=\"https:\/\/help.salesforce.com\/articleView?id=000341701&amp;type=1&amp;language=en_US&amp;mode=1\">this documentation<\/a>.<\/p>\n<\/blockquote>\n<div class=\"rcp_restricted rcp_paid_only\"><div>\n\n\n\t\n\t<form id=\"rcp_login_form\"  class=\"rcp_form\" method=\"POST\" action=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442\/\">\n\n\t\t\n\t\t<fieldset class=\"rcp_login_data\">\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_login\">Username or Email<\/label>\n\t\t\t\t<input name=\"rcp_user_login\" id=\"rcp_user_login\" class=\"required\" type=\"text\"\/>\n\t\t\t<\/p>\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_pass\">Password<\/label>\n\t\t\t\t<input name=\"rcp_user_pass\" id=\"rcp_user_pass\" class=\"required\" type=\"password\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t\t<p>\n\t\t\t\t<input type=\"checkbox\" name=\"rcp_user_remember\" id=\"rcp_user_remember\" value=\"1\"\/>\n\t\t\t\t<label for=\"rcp_user_remember\">Remember me<\/label>\n\t\t\t<\/p>\n\t\t\t<p class=\"rcp_lost_password\"><a href=\"\/wp-json\/wp\/v2\/posts\/31442?rcp_action=lostpassword\">Lost your password?<\/a><\/p>\n\t\t\t<p>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_action\" value=\"login\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_redirect\" value=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442\/\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_login_nonce\" value=\"0c0230e06d\"\/>\n\t\t\t\t<input id=\"rcp_login_submit\" class=\"rcp-button\" type=\"submit\" value=\"Login\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t<\/fieldset>\n\n\t\t\n\t<\/form>\n<br \/>\nNot a subscriber? <a href=\"\/subscriptions\/subscribe\/\">Subscribe now<\/a>.\n<\/div>\n<\/div>\n<h3>Example 1<\/h3>\n<p>The following illustrates the use of this function with the minimum number of arguments.<\/p>\n<p>A sample Data Extension schema for the ClaimRowValue example is provided below.<\/p>\n<p><strong>Data Extension<\/strong>: <em>CouponCodes<\/em><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Name<\/th>\n<th style=\"text-align: left;\">Data Type<\/th>\n<th style=\"text-align: left;\">Length<\/th>\n<th style=\"text-align: center;\">Primary Key<\/th>\n<th style=\"text-align: center;\">Nullable<\/th>\n<th style=\"text-align: left;\">Default Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">CouponCode<\/td>\n<td style=\"text-align: left;\">Text<\/td>\n<td style=\"text-align: left;\">50<\/td>\n<td style=\"text-align: center;\">Y<\/td>\n<td style=\"text-align: center;\">N<\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">IsClaimed<\/td>\n<td style=\"text-align: left;\">Boolean<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: center;\">N<\/td>\n<td style=\"text-align: center;\">Y<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">EmailAddress<\/td>\n<td style=\"text-align: left;\">EmailAddress<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: center;\">N<\/td>\n<td style=\"text-align: center;\">Y<\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ClaimedDate<\/td>\n<td style=\"text-align: left;\">Date<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: center;\">N<\/td>\n<td style=\"text-align: center;\">Y<\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The <em>CouponCodes<\/em> Data Extension could include these initial rows:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">CouponCode<\/th>\n<th style=\"text-align: left;\">IsClaimed<\/th>\n<th style=\"text-align: left;\">EmailAddress<\/th>\n<th style=\"text-align: left;\">ClaimedDate<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">SJOCYUNGIX<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ZURRPSIDQD<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">LFZCWGPFCS<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">KTZUYGCFOZ<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">WDQHIUBVFS<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In this example, checking the <code>_messageContext<\/code> personalization string allows the coupon codes to be preserved while testing the AMPscript function.<\/p>\n<pre><code>%%[\n\nvar @em, @defaultCoupon\n\nset @defaultCoupon = \"SAVE30\"\n\nif _messagecontext == \"PREVIEW\" then\n\n    set @couponCode = \"XX TEST XX\"\n\nelse\n\n    \/* include the send context attributes or columns to record here *\/\n    set @em = AttributeValue(\"emailAddr\")\n\n    set @couponCode = ClaimRowValue(\"CouponCodes\", \"CouponCode\", \"IsClaimed\", @defaultCoupon, \"EmailAddress\", @em)\n\nendif\n\n]%%\n\nCoupon code: %%=v(@couponCode)=%%<\/code><\/pre>\n<h4>Output<\/h4>\n<p>If the AMPscript code referenced previously was executed in an email send to a single Subscriber, <code>doug@limedash.com<\/code>, the following would appear in the email:<\/p>\n<pre><code>Use this coupon code: SJOCYUNGIX<\/code><\/pre>\n<p>The result of the ClaimRowValue function would result in this claimed row in the <em>CouponCodes<\/em> Data Extension:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">CouponCode<\/th>\n<th style=\"text-align: left;\">IsClaimed<\/th>\n<th style=\"text-align: left;\">EmailAddress<\/th>\n<th style=\"text-align: left;\">ClaimedDate<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">SJOCYUNGIX<\/td>\n<td style=\"text-align: left;\">True<\/td>\n<td style=\"text-align: left;\">doug@limedash.com<\/td>\n<td style=\"text-align: left;\">2017-10-10 12:34<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ZURRPSIDQD<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">LFZCWGPFCS<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">KTZUYGCFOZ<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">WDQHIUBVFS<\/td>\n<td style=\"text-align: left;\">False<\/td>\n<td style=\"text-align: left;\"><\/td>\n<td style=\"text-align: left;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If the same code is used and there were no available coupons for claiming, then the function would return the default value specified in the fourth parameter:<\/p>\n<pre><code>Use this coupon code: SAVE30<\/code><\/pre>\n<h3>Example 2<\/h3>\n<div class=\"rcp_restricted rcp_paid_only\"><div>\n\n\n\t\n\t<form id=\"rcp_login_form\"  class=\"rcp_form\" method=\"POST\" action=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442\/\">\n\n\t\t\n\t\t<fieldset class=\"rcp_login_data\">\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_login\">Username or Email<\/label>\n\t\t\t\t<input name=\"rcp_user_login\" id=\"rcp_user_login\" class=\"required\" type=\"text\"\/>\n\t\t\t<\/p>\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_pass\">Password<\/label>\n\t\t\t\t<input name=\"rcp_user_pass\" id=\"rcp_user_pass\" class=\"required\" type=\"password\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t\t<p>\n\t\t\t\t<input type=\"checkbox\" name=\"rcp_user_remember\" id=\"rcp_user_remember\" value=\"1\"\/>\n\t\t\t\t<label for=\"rcp_user_remember\">Remember me<\/label>\n\t\t\t<\/p>\n\t\t\t<p class=\"rcp_lost_password\"><a href=\"\/wp-json\/wp\/v2\/posts\/31442?rcp_action=lostpassword\">Lost your password?<\/a><\/p>\n\t\t\t<p>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_action\" value=\"login\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_redirect\" value=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442\/\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_login_nonce\" value=\"0c0230e06d\"\/>\n\t\t\t\t<input id=\"rcp_login_submit\" class=\"rcp-button\" type=\"submit\" value=\"Login\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t<\/fieldset>\n\n\t\t\n\t<\/form>\n<br \/>\nNot a subscriber? <a href=\"\/subscriptions\/subscribe\/\">Subscribe now<\/a>.\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>ClaimRowValue Like the ClaimRow function, ClaimRowValue returns a single row from a Data Extension and reserves the values to prevent them from being used by another operation. If a row is found and is unclaimed, the designated claimed column is set to true and data from that row is returned. Unlike ClaimRow, if no unclaimed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The AMPscript Guide - ClaimRowValue<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ampscript.guide\/claimrowvalue\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - ClaimRowValue\" \/>\n<meta property=\"og:description\" content=\"ClaimRowValue Like the ClaimRow function, ClaimRowValue returns a single row from a Data Extension and reserves the values to prevent them from being used by another operation. If a row is found and is unclaimed, the designated claimed column is set to true and data from that row is returned. Unlike ClaimRow, if no unclaimed [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/claimrowvalue\/\" \/>\n<meta property=\"og:site_name\" content=\"The AMPscript Guide\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-21T15:47:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-06T12:30:49+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ampscript.guide\/#website\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"The AMPscript Guide\",\"description\":\"The Definitive Scripting Manual for Salesforce Marketing Cloud\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ampscript.guide\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/claimrowvalue\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/claimrowvalue\/\",\"name\":\"The AMPscript Guide - ClaimRowValue\",\"isPartOf\":{\"@id\":\"https:\/\/ampscript.guide\/#website\"},\"datePublished\":\"2018-04-21T15:47:46+00:00\",\"dateModified\":\"2021-08-06T12:30:49+00:00\",\"author\":{\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\"},\"breadcrumb\":{\"@id\":\"https:\/\/ampscript.guide\/claimrowvalue\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/claimrowvalue\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/claimrowvalue\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/claimrowvalue\/\",\"url\":\"https:\/\/ampscript.guide\/claimrowvalue\/\",\"name\":\"ClaimRowValue\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\",\"name\":\"dev\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442"}],"collection":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/comments?post=31442"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31442\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}