on 01-27-2020 4:13 PM
Hi Experts,
I' m using oData v2 batch to make a sequence of post to the backend. In the chrome developer tool I can see the reponse from the backend but this doesnt seem to available in the oData parameter of the success method of the submitchange. The success message is called its only that the parameter doesnt have any value. What I am doing wrong?
var oModel = new ODataModelv2({
serviceUrl: "xxxx",
json: true,
useBatch: true,
tokenHandling: false,
disableHeadRequestForToken: true,
defaultUpdateMethod: "MERGE"
});
oModel.setDeferredGroups(["itemsParentDefGrp"]);
oModel.create("/xxxx", oItem);
oModel.update("/xxxx", oItems);
oModel.setUseBatch(true);
oModel.submitChanges({
success: function (oData) {
sap.m.MessageToast.show(oData.toString());
},
error: function (oError) {}
});
Hi thanuk
You need to pass the groupId while calling the submitChanges method, so that group will be submitted.
https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/submitChanges
Also, while calling the create and update functions, you need to pass the group id, check the below reference
https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/create
So all those create,update calls will be registered for that particular group and then you will submit changes for that particular group.
Thanks,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh,
Thank you for your suggestion. The issue is not that submitChanges isnt triggering a batch request. It triggers a batch call, the data is posted correctly in the backend and the response is visible in Chrome developer tool. What is missing is that in the success method of the Submit call the response is not available.
In any case I tried using the groupId still the response is not available in the success method.
thanuk based on your code, even if you call submit changes function or not, it will still send the request, because you are deffering only the group "itemsParentDefGrp" And the normal create and update calls don't have this group id, so it will 100% send the request if you call the submit changes or not.
I used this many times and fairly confident that the approach I mentioned will definelty work. Could you paste the update code for me to verify it once?
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.