I'm trying to use DELETEDATA function in AMPscript in unsubscribe process in order to remove record from 2 places ( Data Extensions) AMPscript code is not working when adding this part:
SET @TCX_LOCAL = CONCAT("TCX_",@OOCampaignCode,"_LOCAL") DELETEDATA(@TCX_LOCAL,'SubscriberKey',@SubscriberKey,'Locale',@OOLocale,'CampaignCode',@OOCampaignCode)
Can anyone knows what is wrong with this 2 lines? I'm not able to use DELETEDATA function twice?
I will highly appreciate any advice.
best, Natalia
here is my code:
%%[
IF @Operation == 'OptedOut' THEN
SET @OptInStatus = 'OptedOut'
SET @OptOutDate = NOW() UpdateData('T_MSubscribers',1,'SubscriberKey',@SubscriberKey,'OptInStatus',@OptInStatus,'OptOutDate',@OptOutDate)
SET @rows = LookupRows('T_MSubscribers','SubscriberKey',@SubscriberKey)
SET @rowCount = rowcount(@rows)
IF @rowCount > 0 then
for @i = 1 to @rowCount do
SET @row = row(@rows,@i)
SET @OOCampaignCode = field(@row,'CampaignCode')
SET @OOLocale = field(@row,'Locale')
SET @T_NSubscribersDE = CONCAT("TCX_",@OOCampaignCode,"_NewsletterSubscribers")
DELETEDATA(@T_NSubscribersDE,'SubscriberKey',@SubscriberKey,'Locale',@OOLocale,'CampaignCode',@OOCampaignCode)
SET @T_LOCAL = CONCAT("T_",@OOCampaignCode,"_LOCAL")
DELETEDATA(@T_LOCAL,'SubscriberKey',@SubscriberKey,'Locale',@OOLocale,'CampaignCode',@OOCampaignCode)
next @i
ENDIF
]%%