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]%%

1 Answer 1

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? Commented Jan 29, 2020 at 21:40
  • No worries ;-))
    – zuzannamj
    Commented Jan 29, 2020 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .