I am trying to loop through a number of rows, and return only rows with a specific date criteria (customers who has unsubscribed within 200 days). If that criteria is not met, i want to raise an error. I cant get it to raise the error when no rows is found and when the date criterie is not met. Can anyone point me in the right direction? It will be greatly appreciated.
This is the script so far:
<!-- AMPscript start --> %%[ /* declare vars */ var @UnsubscribeCustomer, @UnsubscribeData, @butik, @StoreName, @mail, @antal, @x, @UnsubscribeDate, @rows, @Rows, @Count, @date, @diff SET @butik = StoreId SET @Rows = LookupRows('Customers_web','StoreId', @butik) SET @Count = Rowcount(@rows) IF @Count > 0 THEN for @x = 1 to @Count do SET @Row = Row(@Rows,@x) SET @mail = Field(@Row,21) <br> SET @date = Field(@Row,35) IF @date > DateAdd(Now(1), '-200', 'D') THEN ]%% <span style="font-family:arial,helvetica,sans-serif;"><b>Email address on Customer:</b> <br>%%=v(@mail)=%% <br><br> <b>Date for unsubscription</b>: <br> %%=v(@date)=%%</span><br><br><hr> %%[ SET @Count = @x ENDIF next @x ELSE RaiseError('There is no unsubscriptions for this store') EndIF ]%% <!-- AMPscript End-->
Thank you in advance.