0

I am trying to write a code in SSJS to clear all data in a Data Extensions Below a sample code

    <script runat=server>
    Platform.Load("core","1");

    var CAMPAGNE= DataExtension.Init("CLIENTI_INSERITI_IN_CAMPAGNA");

   CAMPAGNE.Rows.Remove(["PK_CONTATTI_MC"],["4672248"]);
   CAMPAGNE.Rows.Remove(["PK_CONTATTI_MC"],["1112223"]);

</script>

As you can see I delete the single rows....but I'd like to delete all DE.

How can I you achieve this ?

Regards Riccardo Pruner

1 Answer 1

4

Use the DeleteData or DeleteDE functions from Platform functions. These functions are for deleting mass amounts of data from a Data Extension, the Rows.Remove is more for use with manipulating a single row.

DeleteData(S1,A1,A2)

Use this method to delete information from a data extension as indicated by the array containing the listed column name and value pairs. You can include multiple column name and value pairs in a single call. You can use this method in non-sending contexts, such as landing pages. This call returns the number of rows modified.

Arguments

S1 - String value indicating the name of the data extension

A1 - Array containing the names of the columns from the data extension

A2 - Array containing the relevant values in the data extension

Example

<script runat="server">
      var rows = Platform.Function.DeleteData('CustomerData',['LastName'],['Smith']);
 </script>

This example deletes the rows from the data extension with the LastName value of Smith.

DeleteDE(S1,A1,A2)

Use this method to delete information from a data extension as indicated by the array containing the listed column name and value pairs. You can include multiple column name and value pairs in a single call. You can use this method in sendable contexts, such as email messages.

Arguments

S1 - String value indicating the name of the data extension

A1 - Array containing the names of the columns from the data extension

A2 - Array containing the relevant values in the data extension

Example

<script runat="server">
  var rows = Platform.Function.DeleteDE('CustomerData',['LastName'],['Smith']);
</script>

This example deletes the rows from the data extension with the LastName value of Smith.

6
  • Thanks so much. I read this documentation but I should insert a sort of filter to select a specific rows and delete. Otherwise I'd like delete All records in a DE less use a filter.
    – R.Pruner
    Commented Sep 23, 2016 at 13:14
  • add a field named 'secret' to your DE and have all values '1' (can set default value as well so that any time you import into it, it automatically adds the 1 on). This way you can have the filter on that field and value which will delete all Commented Sep 23, 2016 at 13:43
  • Understand! Thanks you so much ;)
    – R.Pruner
    Commented Sep 23, 2016 at 13:46
  • If you need it without a filter, you can do it via an API call (help.marketingcloud.com/en/technical_library/web_service_guide/…) Commented Sep 23, 2016 at 13:47
  • Can be completed with WSproxy now. salesforce.stackexchange.com/a/249181/65280 Commented May 22, 2019 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .