alexP
alexP

Reputation: 3765

Batch update fires all requests

I want to make an update with sap.ui.model.odata.v2.ODataModel like this:

oModel.setUseBatch(true);
oModel.setDeferredGroups(["batchUpdateGroup"]);


oModel.update("/myPath", myData1, {
    groupId: "batchUpdateGroup"
    merge: false
});


oModel.update("/myPath", myData2, {
    groupId: "batchUpdateGroup"
    merge: false
});

oModel.submitChanges({
    groupId: "batchUpdateGroup",
    success: function(oData) {
        console.log("Success!");
    },
    error: function(oError) {
        console.log("Error!");
    }
});

submitChanges fires the update but also other requests from the model like read requests or bindings. What am i doing wrong with the "groupId"?

Upvotes: 0

Views: 946

Answers (1)

Andrew Naumovich
Andrew Naumovich

Reputation: 1450

Because you use wrong syntax of update method.

The right one looks like this:

oModel.update("/myPath", myData1, {
    groupId: "batchUpdateGroup"
});

P.S. if you do not know whether you need to use "changeId", do not use it.

UPD: Also the refreshAfterChange updates all the bindings that your updated entity were involved in.

Upvotes: 1

Related Questions