verified
Clear all Data Extension recordsLearn how to clear (delete) all Data Extension records (rows) in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.
WSProxy
var api = new Script.Util.WSProxy();
var properties = {
CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
};
var action = "ClearData",
options = {};
var result = api.performItem("DataExtension", properties, action, options);
<script runat="server">
Platform.Load("core", "1");
var api = new Script.Util.WSProxy();
try {
var properties = {
CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
};
var action = "ClearData",
options = {};
var result = api.performItem("DataExtension", properties, action, options);
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
{
"Status": "OK",
"StatusMessage": "",
"RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"Results": [
{
"Object": {
"Name": null,
"Description": null,
"IsSendable": false,
"IsTestable": false,
"SendableDataExtensionField": null,
"SendableSubscriberField": null,
"Template": null,
"DataRetentionPeriodLength": 0,
"DataRetentionPeriodUnitOfMeasure": 0,
"RowBasedRetention": false,
"ResetRetentionPeriodOnImport": false,
"DeleteAtEndOfRetentionPeriod": false,
"RetainUntil": null,
"Fields": null,
"DataRetentionPeriod": "Days",
"CategoryID": 0,
"Status": null,
"Client": null,
"PartnerKey": null,
"PartnerProperties": null,
"CreatedDate": "0001-01-01T00:00:00.000",
"ModifiedDate": null,
"ID": 0,
"ObjectID": null,
"CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"Owner": null,
"CorrelationID": null,
"ObjectState": null,
"IsPlatformObject": false
},
"Task": null,
"ProgramActivityInstanceId": null,
"StatusCode": "OK",
"StatusMessage": "Data from requested data extension was cleared successfully. DataExtension - CustomerKey :S0M3-GU1D-K3Y-21NS3RT-H3R3",
"OrdinalID": 0,
"ErrorCode": 0,
"RequestID": null,
"ConversationID": null,
"OverallStatusCode": null,
"RequestType": "Synchronous",
"ResultType": null,
"ResultDetailXML": null
}
]
}
Reference
Ressources and references related to the current methods.
Official documentation
SOAP object