I'm trying to do a batch operation with multiple groupids in a single batch request. and need to get results in two different batch responses.
But when I initiate the request only one group has been submitted and only get one batch response.
Here is my code
oModel = this.getOwnerComponent().getModel("mymodel");
$.sap.itemArray.forEach(function (entry) {
if (p < $.sap.itemArray.length) {
var oData = {
"AUTO_ID": entry.Id,
"VALUE": entry.Value,
};
mParameters.groupId = "createGroup1";
oModel .create("/Table1", oData, mParameters);
}
p++;
});
for (p = 0; p < $.sap.itemArray2.length; p++) {
var oData = {
"Item2ID" : $.sap.itemArray2[p].ItemsId,
"Value" : $.sap.itemArray2[p].Value
};
mParameters.groupId = "createGroup2";
oModel .create("/Table2", oData, mParameters);
}
oModel.setDeferredGroups(["createGroup1","createGroup2"]);
oStyleSizeModel.submitChanges({
success: function(recievedObject){
var responses = recievedObject.__batchResponses;
},
error: function (oError) {
var oBody = oError.responseText;
}
});
Here is the response I got.
And here it only execute the first group's requests and only returned one batch response.
How to execute multiple batch requests with different group Ids and get each group's responses.
I believe you want to group each change separately. You need to use the concept of Change Set (not Group).
create
. changeSetId
, but same groupId
. submitChanges
passing the groupId
.