0

Need to send an Email with coupon code. If a subscribe has received coupon code before send the same code or if did not receive code claim a new coupon code from other Data extension. The below ampscript I wrote which gives an error.

%%[SET @code=Lookup('Jan_Newsletter_USD','secret_word','SubscriberKey',_subscriberkey)

IF EMPTY(@code) THEN
SET @code=Lookup('Jan_Newsletter_CAD','secret_word','SubscriberKey',_subscriberkey)

ELSE

SET @VoucherRow = ClaimRow('Feb_Newsletter_USD', 'IsClaimed','JobID', JobID, 'ListID', listid, 'BatchID', _JobSubscriberBatchID, 'SubscriberKey', _subscriberkey,'IncrementID', 1)

ELSEIF EMPTY(@VoucherRow) Then

 RaiseError('No valid voucher codes', true)

ELSIF

  SET @code = field(@VoucherRow,  'secret_word')

ENDIF
ENDIF]%%
2

I think you mixed up the if/else statements. If you use indentation, it's easier to see where they start and end:

%%[
SET @code=Lookup('Jan_Newsletter_USD','secret_word','SubscriberKey',_subscriberkey)

IF EMPTY(@code) THEN
SET @code=Lookup('Jan_Newsletter_CAD','secret_word','SubscriberKey',_subscriberkey)

ELSE

SET @VoucherRow = ClaimRow('Feb_Newsletter_USD', 'IsClaimed','JobID', JobID, 'ListID', listid, 'BatchID', _JobSubscriberBatchID, 'SubscriberKey', _subscriberkey,'IncrementID', 1)

    IF EMPTY(@VoucherRow) Then

    RaiseError('No valid voucher codes', true)

    ELSE

    SET @code = field(@VoucherRow,  'secret_word')

    ENDIF

ENDIF
]%%
2
  • I accidentally downvoted your answer :-( Can you edit it, as I otherwise can’t retract my vote? – Lukas Lunow Jan 29 '20 at 21:40
  • No worries ;-)) – zuzannamj Jan 29 '20 at 22:15

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.