cancel
Showing results for 
Search instead for 
Did you mean: 

oData V2 submitChanges success parameter not filled

Thanu
Explorer

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) {}
});

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor
0 Kudos

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

Thanu
Explorer
0 Kudos

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.

maheshpalavalli
Active Contributor
0 Kudos

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?

Thanu
Explorer
0 Kudos

Hi Mahesh,

You are right it worked. The mistake I made was that I was passing the correct groupId. Thank you for the info.

javierrubio_01
Explorer
0 Kudos

Hi Mahesh, Thanu,

I am using delete operation and I am passing the Group Id in both remove function ( under mParameters ) and submitChanges method but the response oRes from the OData call is empty.

Do you think the problem lies in the backend method?.

Thanks,

Javier

Answers (0)