Unlock the power of clearing (deleting) all records within Data Extensions in Salesforce Marketing Cloud (SFMC) using Server-Side JavaScript (SSJS). This code snippet leverages the WSProxy method for seamless execution.
<script runat="server">
Platform.Load('core', '1');
var sfmcApi = new Script.Util.WSProxy();
try {
var dataExtensionKey = 'YOUR_DATA_EXTENSION_KEY_HERE';
var properties = {
CustomerKey: dataExtensionKey
};
var action = 'ClearData',
options = {};
var result = sfmcApi.performItem('DataExtension', properties, action, options);
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
Customize the 'YOUR_DATA_EXTENSION_KEY_HERE' with the actual CustomerKey of the Data Extension you wish to clear. This snippet empowers you to efficiently manage your SFMC data with precision and ease.