AMPSCRIPT CLAIMROW FUNCTION

 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.

STEP 2 :
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 ]%%




Comments

  1. Awesome. Please write a blog on automation and journey activities too

    ReplyDelete

Post a Comment


Knowledge Article

Most Viewed

CLOUD PAGE ENABLEMENT - PART 1

EMAIL NOT SENT IN JOURNEY BUILDER

CONSIDERATIONS FOR JOURNEY BUILDER

Journey Builder REST API Documentation

Preference Center Demystified

Popular Posts

CLOUD PAGE ENABLEMENT - PART 1

EMAIL NOT SENT IN JOURNEY BUILDER

CONSIDERATIONS FOR JOURNEY BUILDER

Journey Builder REST API Documentation

Preference Center Demystified

SEND LOG EANBLEMENT

Share with Friends

Disclaimer:

The information provided on this technical blog is for general informational purposes only. As a SFMC (Salesforce Marketing Cloud) Technical Architect, I strive to offer accurate and up-to-date content related to SFMC and its associated technologies. However, please note that technology is constantly evolving, and the information provided may become outdated or inaccurate over time.

The content published on this blog represents my personal views and experiences as a SFMC Technical Architect and does not necessarily reflect the official views or opinions of any organization or employer I may be affiliated with.

While I make every effort to ensure the accuracy and reliability of the information presented, I cannot guarantee its completeness, suitability, or applicability to your specific circumstances. Therefore, it is essential to verify any information provided and make your own independent assessments or seek professional advice if needed.

Furthermore, any actions taken based on the information provided on this blog are at your own risk. I shall not be held liable for any damages, losses, or inconveniences arising from the use of the information presented here.

Please keep in mind that SFMC and its associated technologies are complex and require technical expertise for proper implementation and management. It is recommended to consult with qualified professionals or official SFMC documentation for comprehensive guidance.

Finally, please note that any product or company names mentioned on this blog are trademarks or registered trademarks of their respective owners. The mention of these trademarks or registered trademarks does not imply any endorsement or affiliation with the blog.

By accessing and using this blog, you agree to the terms of this disclaimer. If you do not agree with any part of this disclaimer, please refrain from using this blog.