Skip to Content

TypeError in deferredgroup, when trying to submit a batch with a SAPUI5 V2 ODataModel

Hi,

I am trying to figure out how to create a odata batch and submit the changes to the backend with a V2 ODataModel.

This is my code:

onSendBatch: function(oEvent) {

var oModel = this.getView().getModel();

var aDeferredGroup = oModel.getDeferredGroups().push("batchCreate");

oModel.setDeferredGroups(aDeferredGroup); var mParameters = {groupId:"changes"};

var changeOne = { "__metadata": { "uri": "/User('107017')" }, "firstName" :"EmilTest5" };

oModel.create("/User", changeOne, mParameters);

oModel.submitChanges(mParameters);

}

I have found this solution from this thread:

https://stackoverflow.com/questions/42696398/sapui5-create-multiple-valuebatch-using-post

However, I'm getting this error:

I have found out that this error is simply because I am trying to access something in a String - or in this case "2", which is the deferredgroup-array length.

But I do not understand why I even have an error here, as I dont see how this should be a problem compared to what the solution is in StackOverflow link.

Edit:

I should point out that what I need to do is both be able to create new entries like a new user, but also update one, like here where I want to change the firstname of the user.

Best regards

Emil Sarkisi Stepanian

error.png (68.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers