Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save katydorjee/24fa882a02656619c869ea9bd0e005cc to your computer and use it in GitHub Desktop.
Save katydorjee/24fa882a02656619c869ea9bd0e005cc to your computer and use it in GitHub Desktop.
Delete a record from DataExtension using AMPscript
%%[
SET @status = DeleteData("DataExtension Name", "SubscriberKey","XXXXXXXXXX")
]%%
Status: %%=v(@status)=%%
@katydorjee
Copy link
Author

katydorjee commented Sep 11, 2020

Converting to SSJS:

<script runat='server'>
Platform.Load('Core','1');
try{
var DE_name = 'XYZ';
var FeildName = 'SubscriberKey';
var FeildValue = 'XXXXXXXXXX';
var ampscriptStr = '%'+'%[SET @deleteCount = DeleteData("'+DE_name+'","'+FeildName+'","'+FeildValue+'")]%'+'%';
Platform.Function.TreatAsContent(ampscriptStr);
Write(Platform.Variable.GetValue("@deleteCount"));
}catch (ex){
Write(Stringify(ex));
}
</script>

@katydorjee
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment