I have problem with IF/ELSE statement in Ampscript ,as it is not going through else statement
I have created a DE for couponcode Claim coupon DE details(CouponCodeRedeem) CouponCode - CouponCode EmailAddress - Email to which coupon is sent IsClaimed - is set to Y once emai; with is sent to customer IsRedeemed - updated based on external system response ; used to send reminder email if coupon is not redeemed.
Receipient DE details EmailAddress - email address of the recipient Name - name of recipient
i have populated "coupon code for 3 rows in my DE , where IsRedeemed is set to Y for 1 coupon code and remaining 2 rows have value has false .
I'm trying to send coupon to customers for which new customers( IsRedeemed ="False") , but it is not going thorugh my else statement and check my if statement and sends the coupon for (Isredeemed = True) for 1 recipient .
%%[ var @email,@row,@couponRow, @couponCode,@ClaimedDate,@IsRedeemed,@barcode set @rows = LookupRows("CouponCodeRedeem","IsRedeemed","Y") set @rowCount = rowcount(@rows) if @rowCount > 0 then output(concat("rowcount: ", @rowcount)) for @i = 1 to @rowCount do var @emailAddress, @couponCode set @row = row(@rows, @i) /* get row based on counter */ set @emailAddress = field(@row,"EmailAddress") set @couponCode = field(@row,"CouponCode") ]%% <br>Row %%=v(@i)=%%, couponCode: %%=v(@couponCode)=%%, emailAddress: %%=v(@emailAddress)=%% %%[ next @i ]%% %%[ else ]%%/*setting coupon against new customers*/ set @email = AttributeValue("emailAddr") output(concat("email: ", @email)) set @couponRow = ClaimRow("CouponCodeRedeem", "IsClaimed", "EmailAddress", @email) if not empty(@couponRow) then set @couponCode = Field(@couponRow, "CouponCode") set @barcode = BarcodeURL(@couponCode, "Code128Auto", 300, 100) set @ClaimedDate = Field(@couponRow, "ClaimedDate") else RaiseError("No coupons available") %%[ endif ]%%