Loading

Marketing Cloud Delete Data Extensions in bulk with SSJS

Publiseringsdato: Nov 11, 2025
Beskrivelse

In the business unit in which you need to delete data extensions make the following DE

Name: DEtoDelete
External Key: DEtoDelete
 

Field NameData TypeLengthPrimary Key NullableDefault Value
DENameText254NoNoNot Applicable
isprocessedBooleanNot ApplicableNoNoFalse



Populate the DE with the DE names which need to be deleted.

Create an SSJS activity with the following code

<script runat="server">
  Platform.Load("core", "1.1.1");
 
  var api = new Script.Util.WSProxy();
  var rowstoprocess = DataExtension.Init("DEtoDelete").Rows.Lookup(["isprocessed"],[0])
    
    for(j=0; j < rowstoprocess.length; j ++ ) 
 {
  var dataExtensionName = rowstoprocess[j].DEName

  var req = api.retrieve("DataExtension", ["CustomerKey"], {
   Property: "Name",
   SimpleOperator: "equals",
   Value: dataExtensionName
  });

  var customerKey = req.Results[0].CustomerKey;

  var res = api.deleteItem("DataExtension", { "CustomerKey":customerKey });

  DataExtension.Init('DEtoDelete').Rows.Update({"isprocessed": "1"}, ["DEName"], [dataExtensionName]);
 }
</script>
Løsning

Run the above SSJS activity to delete any data extensions within the DE "DEtoDelete"

Each occurance of the script will delete only 2000 DE, to delete more, run the activity additional times

If the SSJS errors with a timeout (30mins) run the activity again to delete the remaining DEs

Knowledge-artikkelnummer

000395614

 
Laster
Salesforce Help | Article