0

I am looking to delete rows from "ProxyTest22" data extension and trying to achieve this through WSProxy as the number of rows are in millions. I keep getting Error executing delete call.\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon --> \r\n\r\n --- inner exception 1---\r\n\r\nSystem.TypeLoadException: Could not load type 'ProxyTest22' from assembly 'OMMCommon, Version=228.7.0.4, Culture=neutral, PublicKeyToken=c3ca85e74a7e49d9'. - from mscorlib error when running this in cloudpage.

I would really appreciate if someone can look into this script and advise.

<script runat="server">
Platform.Load("core","1.1.1");
try{

var prox = new Script.Util.WSProxy(); 
var deCustKey = 'ProxyTest22'; //DE's CustomerKey
var moreData = true; 
var reqID = null; 

while(moreData) {

    var moreData = false;

    var deReturn = retrieveDERows(deCustKey,reqID);

    var moreData = deReturn.HasMoreRows;
    var reqID = deReturn.RequestID;
    var attributes = [];
    //Write("\n RequestID ********************* " + reqID);

    for (var a = 0; a < deReturn.Results.length; a++) {
        var results = deReturn.Results[a];

        for (var i = 0; i < results.Properties.length; i++) {

            var name =  results.Properties[i].Name;
            var value = results.Properties[i].Value;
            var object = Platform.Function.ParseJSON('{Name:"' + name + '",Value:"' + value + '"}')
            //Write("\n Object Value " + object.Value);
            attributes.push(object);
        }
        
     }
     var deletedItems = prox.deleteBatch("DataExtensionObject[" + deCustKey + "]", attributes);
      
    }

function retrieveDERows(deCustKey,reqID) {

    var cols = ["id"]; //DE Column Name to be retrieved

    if (reqID == null) {
        var desc = prox.retrieve("DataExtensionObject[" + deCustKey + "]", cols); //executes the proxy call
    } else {
        desc = prox.getNextBatch("DataExtensionObject[" + deCustKey + "]", reqID);
    }

    return desc;
}
}catch (e) {
    Write("<br>e: " + Stringify(e));
}

</script>
0

I modified your code a bit and the rows were deleted. Took reference from here

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

var prox = new Script.Util.WSProxy(); 
var deCustKey = '12345; //DE's CustomerKey
var moreData = true; 
var reqID = null; 

while(moreData) {

    var moreData = false;

    var deReturn = retrieveDERows(deCustKey,reqID);

    var moreData = deReturn.HasMoreRows;
    var reqID = deReturn.RequestID;
    var attributes = [];
    //Write("\n RequestID ********************* " + reqID);

    for (var a = 0; a < deReturn.Results.length; a++) {
        var results = deReturn.Results[a];

        for (var i = 0; i < results.Properties.length; i++) {

            var name =  results.Properties[i].Name;
            var value = results.Properties[i].Value;
           /* var object = Platform.Function.ParseJSON('{Name:"' + name + '",Value:"' + value + '"}')
            //Write("\n Object Value " + object.Value);*/
          
             attributes.push({
    CustomerKey: deCustKey,
    Keys: [{Name:"id", Value:value}]
  });
            
        }
        
     }
  Write(Stringify(attributes));
    var deletedItems = prox.deleteBatch("DataExtensionObject", attributes);
      Write("<br><br>" + Stringify(deletedItems));
    }

function retrieveDERows(deCustKey,reqID) {

    var cols = ["id"]; //DE Column Name to be retrieved
    
    if (reqID == null) {
        var desc = prox.retrieve("DataExtensionObject[" + deCustKey + "]", cols); //executes the proxy call
        
    } else {
        desc = prox.getNextBatch("DataExtensionObject[" + deCustKey + "]", reqID);
    }

    return desc;
}
}catch (e) {
    Write("<br>e: " + Stringify(e));
}

</script>
1
  • Thank You @SwatiMishra. I am able to delete the DE rows that has only 1 Primary Key. Getting error when deleting the rows with multiple(2 or more) Primary Key. Receiving ErrorMessage":"Cannot locate the existing record. Required keys are missing. error. Probably would have to change the var attributes = []; to an Object <salesforce.stackexchange.com/questions/297133/…> The DE Properties with two PK "Properties":[{"Name":"PrimaryKey1","Value":"xxxxxxx"},{ "Name":"PrimaryKey2","Value":"yyyyyyy"} ] – Sudhir Dec 10 '20 at 2:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.