Last active
August 25, 2020 03:59
-
-
Save katydorjee/069c9dc16e79d5d5dc2d124ecd4eb0a8 to your computer and use it in GitHub Desktop.
Delete records from a Data Extension using SSJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
Platform.Load("core","1"); | |
try { | |
var DE_name = 'DataExtension Name'; | |
var Lookup_value = 'lookup value'; | |
var dataRows = Platform.Function.LookupRows(DE_name,'Lookup_Fieldname',Lookup_value); | |
if(dataRows && dataRows.length > 0) { | |
var rows = Platform.Function.DeleteData(DE_name,'Lookup_Fieldname',Lookup_value); | |
Write(Stringify('Rows deleted: '+rows)); | |
}else | |
{ | |
Write('There is no record to delete'); | |
} | |
} | |
catch(err) { | |
Write(Stringify(err)); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment