0

We have an email that we are populating with certain coupons that customers qualify for. Customers can qualify for up to 3 coupons that are tied to SUI codes, but only one coupon can be displayed at one time. As customers redeem coupons that SUI code is removed from the data ext. and the current Ampscript only recognizes the first SUI code (SUI1), so if it's null nothing is displayed.

What I want to do is replace SUI1, if null, with another SUI, SUI2 or SUI3, but the current Ampscript I'm using isn't working. Has anyone done anything like this and gotten it to work? Any tips on my code to get it working? Thx.

%%[ 
var @Tracking_ID_1, @Tracking_ID_2, @Tracking_ID_3, @Lookup1, @Lookup2, @Promo_Code, @Lookup3, @Lookup4, @Lookup5, @Lookup6
    
set @Tracking_ID_1 = [Reward_marketing_tracking_id_1]
set @Tracking_ID_2 = [Reward_marketing_tracking_id_2]
set @Tracking_ID_3 = [Reward_marketing_tracking_id_3]
set @Lookup1 = @Reward_marketing_tracking_id_1
Set @Lookup2 = @Reward_Promo_Code_1
set @Lookup3 = @Reward_marketing_tracking_id_2
Set @Lookup4 = @Reward_Promo_Code_2
set @Lookup5 = @Reward_marketing_tracking_id_3
Set @Lookup6 = @Reward_Promo_Code_3
Set @Delivery = Lookup("Certificate and Coupons FINAL", "Delivery_Method", "Marketing_Tracking_ID", @Lookup1, "Promo_Code", @Lookup2)
]%% 

%%[ 
    IF isNull(@Lookup1) then
    set [@Tracking_ID_1] = [reward_marketing_tracking_id_2]
    ELSEIF isNull(@Lookup3) then
    set [@Tracking_ID_1] = [reward_marketing_tracking_id_3]
    ENDIF
]%%
    
%%[ IF @Delivery == 'Email' then Set @SUIText = 'Enjoy this email exclusive offer' 
    ELSEIF @Delivery == 'Postal' then set @SUIText = 'Here''s a copy of the offer you received in the mail' ENDIF 
IF @Delivery == 'Email' then set @SUIDisclaimer = 'email and online.' 
    ELSEIF @Delivery == 'Postal' then set @SUIDisclaimer = 'mail, email and online.' ENDIF 
%%[endif]%% 
%%[IF NOT Empty (@Alpha_trigger_1) THEN]%%

1 Answer 1

1

I will be honest, I am very confused on what your code is doing, so I am gonna make an example that is a bit more generic that hopefully you can then use for your use case.

%%[ 
set @Tracking_ID = AttributeValue("Reward_marketing_tracking_id_1")

IF EMPTY(@Tracking_ID) THEN
  set @Tracking_ID = AttributeValue("Reward_marketing_tracking_id_2")
ENDIF

IF EMPTY(@Tracking_ID) THEN
  set @Tracking_ID = AttributeValue("Reward_marketing_tracking_id_3")
ENDIF

SET @promo_RS = LookupRows("MyCouponDE", "Marketing_Tracking_ID", @Tracking_ID)
SET @Row = Row(@promo_RS,1)
SET @promo_code = FIELD(@Row,"Promo_Code")
SET @Delivery =  FIELD(@Row,"Delivery_Method")
    
IF @Delivery == 'Email' then 
  Set @SUIText = 'Enjoy this email exclusive offer' 
ELSEIF @Delivery == 'Postal' then 
    set @SUIText = 'Here''s a copy of the offer you received in the mail' 
ENDIF 
IF @Delivery == 'Email' then 
    set @SUIDisclaimer = 'email and online.' 
ELSEIF @Delivery == 'Postal' then 
    set @SUIDisclaimer = 'mail, email and online.' 
ENDIF 
]%%
This is your promo code %%=v(@promo_code)=%%

The IF statements after the initial setting of @Tracking_ID should fill in ID 2 or 3 if the previous one was empty/null.

Hopefully this is what you were looking for.

1
  • Thank you. I'll give this a try!
    – Chris-L
    Commented Sep 8, 2022 at 16:07

You must log in to answer this question.

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