[SalesForce] Exact Target Ampscript Data Extension Key, what is it

I'm attempting to follow the first example shown on http://help.exacttarget.com/en-US/documentation/exacttarget/content/ampscript/ampscript_syntax_guide/data_extension_ampscript_functions/ and it says that variable 3 and 4 are related to the data extension key but it doesn't specify what it is.

S1 The name of the data extension for the claim or retrieve action

S2 The name of the column in the data extension that indicates whether the row is claimed or not

S3 The name of the data extension key column

S4 The value of the data extension key column

Based on their example code and database they show i'm going to assume that data extension key is not the Primary Key in the data table. It also doesn't appear to be the data extensions External Key. So what is it?

Here is my current Ampscript

%%[VAR @CouponRow
SET @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "newsletter_coupon_20_key", newsletter_coupon_20_key )
IF EMPTY(@CouponRow) THEN ]%%
No Coupon Available
%%[ ELSE ]%%
Coupon Code = %%= FIELD(@CouponRow, "coupon_code") =%%
%%[ ENDIF ]%%

It returns this error when I try to validate it

Error 1: Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: ClaimRow("newsletter_coupon_20", "IsClaimed", "newsletter_coupon_20_key", newsletter_coupon_20_key ) MemberID: redacted JobID: 0 The specified attribute or custom object field name was not found for this client. Function Call: ClaimRow("newsletter_coupon_20", "IsClaimed", "newsletter_coupon_20_key", newsletter_coupon_20_key ) Attribute or Field Name: newsletter_coupon_20_key
Invalid Content:
SET @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "newsletter_coupon_20_key", newsletter_coupon_20_key )

I've been digging around in the Exact Target Help and I can't locate a description of what the Data Extension Key is.

Best Answer

This is referring to a field in the coupon data extension, and the value you would like to populate it with. You can populate extra fields in the coupon data extension so that you can reference information about who claimed the coupon. The example on ET's help docs uses JobID, ListID, BatchID, SubscriberID, EmailAddress and ClaimedDate.

The reason you are getting an error because you are trying to insert the value of the attribute newsletter_coupon_20_key into the field newsletter_coupon_20_key in the data extension newsletter_coupon_20. This attribute either does not exist in your profile attributes, or in the Sendable DE you are attempting to deploy to, or the field "newsletter_coupon_20_key" does not exist in the coupon DE.

If you want the bare minimum for claiming a row, you could simply write:

SET @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed")

However I do not recommend this approach because you are left with almost no information on who claimed the coupon or when that happened.

My suggestion is to set up the coupon DE using ET's example specification, which looks like this: Coupon Data Extension Example

Then, the code to claim a row would look like this:

set @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "JobID", JobID, "ListID", ListID, "BatchID", _JobSubscriberBatchID, "SubscriberID", SubscriberID,"EmailAddress",EmailAddress) 

(Notice the correlation between the DE fields, and the name/value pairs in the function)

You may also wish to add additional fields to the coupon DE. For instance you may want to add a "CampaignName" field, and populate it with the friendly name "Newsletter". Adding that would look something like this:

set @CouponRow = ClaimRow("newsletter_coupon_20", "IsClaimed", "CampaignName", "Newsletter")

Note that "Newsletter" is a string, not a variable, which is why it is in quotes.

Related Topic