Search code examples
salesforcelivecouponampscript

How to replace the soon-to-be deprecated Salesforce functionalities provided by Live Offers and Live Coupons?


With respect to Salseforce's Live Offers and Live Coupons being deprecated in 2020, I am looking for replacement functionality to provide the same features.


Solution

  • I came across this post where the answer does not make sense. Here's why: the suggested answer recommended adding a For loop to the process. That would add an additional loop to the process, the first being the auto-iteration through the subscriber list. The additional For loop would loop through all coupon codes for each subscriber. Not optimal.

    However the use of the ClaimRow() function is key here, where it auto-populates the ClaimedDate attribute with the date claimed and the IsClaimed attribute to true.

    This function 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. If no unclaimed rows are available in the Data Extension, this function will return an error. Claimed rows can be used again if the designated claimed column changes back to false.

    The row is also locked during this process.

    Coupon Data Extension

    This function is primarily used for assigning unique coupon codes to an audience at send time and recording other pertinent data from the send context.

    Using the ClaimRow function and the email address from the initial subscriber loop, I was able to update the coupons table:

     SET @CouponRow = ClaimRow("CouponsTest2DE", 'IsClaimed', 'SubscriberKey', emailaddr)
    

    Where emailaddr is the subscriber's email address from the initial subscriber list iterator.