0

I was able to update 1 record at a time using this code:

var prox = new Script.Util.WSProxy();

var props = [
        {
            "Name": "Contact_Key",
            "Value": "QA_2"
        },
        {
            "Name": "Random_Field",
            "Value": "4444"
        }
    ];

    var options = {
        SaveOptions: [
            {
                PropertyName: 'Random_Field',
                SaveAction: 'UpdateAdd'
            }
        ]
    };

    try {

        var result = prox.updateItem("DataExtensionObject", {
            CustomerKey: "XXXXXX",
            Properties: props
        }, options);
        Write(Stringify(result));

    } catch (error) {
        Write(Stringify("error: " + error));

    }

Reference: Update via WSProxy

In the same doc, it's mentioned there is an option to use updateBatch instead of updateItem. But I was not able to make it work.

Any Idea how to make it work? Or any other suggestion on how to update mass quantity of rows (over 2500) in a DE?

My target is to update all rows with a condition to a value (like true/false)

2
  • Why not use SQL for these mass updates of data extension? Mar 27 at 13:47
  • 2 reasons, first I need it to be dynamic with DEs. We do not know in advance which DE to update. Second, this needs to be updated right after some API call is executed usefully. could not find a way to implement that with SQL.
    – yoni349
    Mar 28 at 7:27

1 Answer 1

0

Found how to parse data, this one works:

var prox = new Script.Util.WSProxy();
var data = [{
        CustomerKey: "<DE external key>",
        Properties: [
            {
                "Name": "<PK search field>",
                "Value": "QA_1"
            },
            {
                "Name": "<Field to update>",
                "Value": "<New value>"
            }
        ]
    },
    {
        CustomerKey:  "<PK search field>",
        Properties: [
            {
                "Name": "<PK search field>",
                "Value": "QA_2"
            },
            {
                "Name": "<Field to update>",
                "Value": "<New value>"
            }
        ]
    }]

    var options = {
        SaveOptions: [
            {
                PropertyName: 'Field to update',
                SaveAction: 'UpdateAdd'
            }
        ]
    };

    try {
        var result = prox.updateBatch("DataExtensionObject", data, options);
        Write(Stringify(result));

    } catch (error) {
        Write(Stringify("error: " + error));

    }

Keep adding objects to the data array for each row you wish to update.

You must log in to answer this question.

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