0

Can someone please help me? I want to delete data from Data Extensions, and I tried different variations. But unfortunately, it didn't work. For info I have so far used variant 1 without any problems. The DE "Used for sending" = NO, USED FOR TESTING = "NO" My Source Code:

 <script runat=server>
Platform.Load("core", "1.1.1");
//-----Start-- write log to DE 

function WriteLog(message, status) {
    var processLogsDE = DataExtension.Init('ent.test_LogXXXXXXXXXX');
    processLogsDE.Rows.Add({ 'message': message, 'status': status });
}

function WriteErrorLog(message) {
    WriteLog(message, 'ERROR');
}

function WriteInfoLog(message) {
    WriteLog(message, 'INFO');
}

//-----End-- write log to DE 


WriteInfoLog("Start");

var source_DE_name = 'ent.test_XXXXXXX_be_deleted'; 

var dataRows = Platform.Function.LookupRows(source_DE_name, 'remove', 'True');

if (dataRows && dataRows.length > 0) {
    WriteInfoLog("1");
    for (var i = 0; i < dataRows.length; i++) {
        var email_address = dataRows[i].EmailAddress;
        WriteInfoLog("2");
        WriteInfoLog("3 Email:" + email_address);
        WriteInfoLog("4");
        var from_DE_name = 'ent.White Night – 2018';

        try {
            // 1. variant
            var row_number = Platform.Function.DeleteData(from_DE_name, ['email'], [email_address]);
            // 2. variant 
            //var row_number = Platform.Function.DeleteData(from_DE_name, "email", email_address);
            //3. variant 
            // var deleteDE = DataExtension.Init(from_DE_name);
            // deleteDE.Rows.Remove(["email"], [email_address]);

            WriteInfoLog("[Delete Contact from DE: " + from_DE_name + "] [Email: " + email_address + " ]");

        } catch (e) {
            WriteErrorLog(Stringify(e));
        }
    }
}
WriteInfoLog("END");

</script>

Result:

result from variant 1

{"message":"An error occurred when attempting to execute an DeleteData function call.
 See inner exception for details.","description":"ExactTarget.OMM.FunctionExecutionException:
 An error occurred when attempting to execute an DeleteData function call.
 See inner exception for details.\r\n  Error Code: OMM_FUNC_EXEC_ERROR\r\n 
- from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.OMMException:
 An error occurred when attempting to execute an update of the database.
  See inner exception for details.\r\n\r\n  StackID: 7\r\n  EnterpriseID: XXXXXXX\r\n
  ClientID: XXXXXX\r\n  Client Database ID: XXXX\r\n  Account Type: BUSINESS_UNIT\r\n
  JobID: 0\r\n  MachineName: XXXXXX\r\n\r\nSql Text:\r\nDELETE [CXXXXX].[White Night – 2018]
 WHERE [email] = @p0_0;\r\n\r\nSql Parameters:\r\n  0: [NVarChar] @p0_0 = XXXXXXXX@gmail.com\r\n\r\n
  Error Code: OMM_SQL_UPDATE_ERR\r\n - from OMMCommon --> \r\n\r\n --- inner exception 2---\r\n\r\nSystem.Data.SqlClient.SqlExcept  ERROR

result from Variant 2

{"message":"Unable to retrieve security descriptor for this frame.","
description":"System.InvalidOperationException: 
Unable to retrieve security descriptor for this frame. - from mscorlib\r\n\r\n"}    ERROR

result from Variant 3

"There was an error Removing the row(s)."   ERROR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.