1

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, 2023 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, 2023 at 7:27

1 Answer 1

1

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.

3
  • Did you find batch to be any faster? Mar 6 at 20:39
  • 1
    @StanAlachniewicz, yes. And also there is no limit of 2500 rows like in AMPSCRIPT and other SSJS functions.
    – yoni349
    Mar 7 at 8:22
  • Yep I got it working. I was able to use an ssjs activity to write 10,000 rows of html to a data extension, but any more than that would time out. I used the VAWP link and HTTPGET in a loop so there was a lot of data. Mar 8 at 23:54

You must log in to answer this question.

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