AMPSCRIPT CLAIMROW FUNCTION
CLAIMROW FUNCTION IS USED TO VALIDATE THE UNCLAIMED COUPONS AND ASSIGN COUPON CODE TO THE SUBSCRIBER CONTEXT. CLAIMROW FUCNTION PREVENTS THE INFORMATION FROM USE IN ANOTHER CONTEXT UNITL THE CLAIMED STATUS IS CHANGED TO "FALSE"
SYNTAX:
CLAIMROW(1,2,3,4)
IF YOU WANT TO LEARN MORE IN DETAILS ABOUT CLAIM ROW FUNCTION CLICK
HERE
STEP BY STEP GUIDE HOW TO DESIGN YOUR USE CASE
STEP 1:
CREATE A MATER DATA EXTENSION TO STORE COUPONS: COUPONMASTER
DATA STRUCTURE HAS TO BE DEFINED AS MENTIONED IN THE OFFICIAL DOCUMENTATION.
CREATE A SENDABLEABLE DATA EXTENSION TO TARGET SUBSCRIBERS: CLAIMCOUPON
STEP 3 :
CREATE A PERSONALISED LOGGING DATA EXTENSION : PERSONALIZATIONLOG
STEP 4 :
BUILT YOUR EMAIL AND THE BELOW AMPSCRIPT BLOCK :
%%[
SET @subscriberKey=AttributeValue('SubscriberKey')
SET @CouponRow = ClaimRow(
'CouponMaster',
'IsClaimed',
'JobID', JobID,
'ListID', ListID,
'BatchID', _JobSubscriberBatchID,
'SubscriberID', SubscriberID
)
]%%
%%[IF EMPTY(@CouponRow) THEN
INSERTDE(
'PERSONALIZATIONLOG',
'ERRORMESSAGE','No Unclaimed Coupon Code',
'ERRORCODE','E003',
'ERRORNUMBER','1234',
'SUBSCRIBERKEY',_SUBSCRIBERKEY,
'JOBID',JOBID
)
RAISEERROR('No Unclaimed Coupon Code',1,'COUPON ERROR','1234',0) ]%%
%%[ ELSE ]%%
Your Coupon Code is %%= FIELD(@CouponRow,'CouponCode') =%%
%%[ ENDIF ]%%
YOU CAN BUILT YOUR HTML EMAIL AS PER MARKET GUIDELINES AND TEMPLATES.
STEP 5 :
POINTS TO CONSIDER
- WHEN YOU PREVIEW & TEST FOR THE FIRST TIME CLAIMROW FUCNTION SETS THE ISCLAIMED ATTRIBUTE TO TRUE AND OTHER ATTRIBUTES SUCH AS JOBID, LISTID, BATCH ID WOULD BE SET TO "0". AND, IF YOU SEND EMAIL AFTER PREVIEW AND TEST, IT WILL RETURN AN ERROR , IF YOU HAVE NO UNCALIMED COUPON FOR THE SUBSCRIBER
- INDEXING IS AUTOMATICALLY SET FOR SENDABLE DATA EXTENSIONS, IF YOUR COUPON MASTER DATA EXTESNION IS NOT SUPPORTING INDEXING , PLEASE DISCUSS WITH YOUR ACCOUNT EXECUTIVE TO SET INDEX TO NON SENDABLE DATA EXTESNION. IF YOU WANT TO LEARN MORE ABOUT INDEXING CLICK HERE.
- OTHER POINTS TO CONSIDER ARE DEFINED IN AMPSCRIPT GUIDE BLOG HERE. PLEASE READ THE NOTES AS MENTIONED AMPSCRIPT GUIDE AND BOOKMARK THE BLOG FOR FUTURE REFERNECES.
- IF YOU WANT TO PREVIEW & TEST APPLY _MESSAGECONTEXT= 'PREVIEW'. IF YOU WANT TO LEARN MORE ABOUT _MESSAGECONTEXT CLICK HERE .
%%[
SET @subscriberKey=AttributeValue('SubscriberKey')
IF _messagecontext == 'SEND' THEN
SET @CouponRow = ClaimRow(
'CouponMaster',
'IsClaimed',
'JobID', JobID,
'ListID', ListID,
'BatchID', _JobSubscriberBatchID,
'SubscriberID', SubscriberID
)
ELSE IF _messagecontext == 'PREVIEW' THEN
SET @CouponRow='DUMMY25'
ENDIF
]%%
%%[IF EMPTY(@CouponRow) THEN
INSERTDE(
'PERSONALIZATIONLOG',
'ERRORMESSAGE','No Unclaimed Coupon Code',
'ERRORCODE','E003',
'ERRORNUMBER','1234',
'SUBSCRIBERKEY',_SUBSCRIBERKEY,
'JOBID',JOBID
)
RAISEERROR('No Unclaimed Coupon Code',1,'COUPON ERROR','1234',0) ]%%
%%[ ELSE ]%%
Your Coupon Code is %%= FIELD(@CouponRow,'CouponCode') =%%
%%[ ENDIF ]%%
Awesome. Please write a blog on automation and journey activities too
ReplyDeleteThanks, Definitely
Delete