0

I'm working on a bit of AMPscript that first does a Lookup on a Coupon Table. If the user is not on the table, it claims a row. If the user is already on the table, it displays the coupon code.

This appears to be working fine.

However, the content that surrounds the coupon code values is not changing. This is especially weird because the LOOKUP and IsClaimed each appear in their own snippet of the IF/THEN/ELSE statement.

I've also tried breaking out the code into Content Segments to see if this would work when the display of information was taken out of the main code (it doesn't)

%%[SET @code = Lookup("Birthday_Coupons","CouponCode","EmailAddress", emailaddr)]%%

%%[IF Empty(@code) == "True" THEN ]%%
COPY GOES HERE<br />
<strong>Coupon Code: %%= ClaimRowValue("Birthday_Coupons","CouponCode","IsClaimed", ,"JobID",JobID, "ListID",ListID,"EmailAddress", emailaddr) =%%

%%[ELSE]%%

COPY GOES HERE<br />
<strong>%%= Lookup("Birthday_Coupons","CouponCode","EmailAddress", emailaddr) =%%</strong>
  • 1
    2 things. 1 - it doesn't sound like you need the Lookup function at all. The ClaimRow() function does the work it's doing for you. That is, it'll show the coupon code if the subscriber already has a coupon, and claim a row if they don't. 2 - If the code posted above is the complete code, the issue might be that you are missing the closing ENDIF for your statement. – Eduardo Arias Feb 2 '18 at 21:40
  • Thank you for the comment. The ENDIF is indeed there - the email deploys, it just doesn't change the content as requested. However, given your point on the CLAIM ROW function, perhaps this is not possible to do since the recipient will always have a code? – George Rosedale Feb 2 '18 at 22:20
  • It's possible - that is, the code can be wrapped to conditionally call in the ClaimRow() function or not. I'm hoping to convey that based on the snippet above, you don't need it. It assumes that everyone getting the email either already has a coupon code associated with their email, or will get one. – Eduardo Arias Feb 5 '18 at 17:22
0

Can you please elaborate on what you mean by "the content that surrounds the coupon code values is not changing." ..... I know this might sound daft, but in your example code, you are printing COPY GOES HERE in both, so it would appear the same regardless of the permission that is being met.

If you mean that you always get 'Coupon Code' it's probable that you keep hitting the condition

IF Empty(@code) == "True" THEN 

And it keeps returning a new coupon?

It would be useful to know/see what you are getting Vs what you expected to get. It would also be useful to understand the structure coupon code DE - certainly interested to know what fields you have and any primary keys.

  • "Content Goes Here" is actually different. Where the coupon is NULL/Empty, it basically says "Here's your coupon code" Where the coupon is NOT NULL, it basically says "Here's your coupon code again, remember to use it" – George Rosedale Feb 5 '18 at 15:41
0

Try this:

%%[
VAR @code
SET @code = ClaimRow('Birthday_Coupons', 'IsClaimed', 'JobID', JobID, 'ListID', 
ListID, 'BatchID', _JobSubscriberBatchID, 'EmailAddress', emailaddr)
IF EMPTY(@code) THEN ]%%
Coupon code: No coupon code available
%%[ ELSE ]%%
Your Coupon Code is %%= FIELD(@code,'CouponCode') =%%
%%[ ENDIF ]%%
  • Thanks for this, but there are coupon codes available. The question is whether or not the recipient received a coupon email before (and is now receiving the reminder) or if the coupon code is newly issued. The concern is that someone can qualify for the coupon in the time period between the initial assignment of a code and the reminder email for that code. – George Rosedale Feb 5 '18 at 15:44
  • Not sure if I am following based on your OP, but my suggestion would be to setup a query to pull all records that have received the initial communication (query off EmailName in job table). From there, you can do a lookup in that table to determine if you need to claim a row from the coupon table or if you need to notify them that this is a newly issued code. – Realrx7 Feb 5 '18 at 20:29
  • it's definitely an option, I just didn't want to go that route. Thanks – George Rosedale Feb 6 '18 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.