on 10-16-2015 10:34 AM
Hi,
I'm having trouble with the calback functions of the submitChanges() method JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.v2.ODataMod...
My code is as follows:
oDataModel.setUseBatch(true);
oDataModel.create("/SomeEntity", data, {
"changeSetId": "create"
});
oDataModel.callFunction("/SomeFunctionImport", {
"method": "POST",
"changeSetId": "function"
});
oDataModel.submitChanges(function(oEvent){
alert("Success");
}, function(oEvent){
alert("failure");
});
The submitChanges call goes through without any problems. The problem is that the error/success handlers doesn't get called. The documentation has the following note:
"Important: The success/error handler will only be called if batch support is enabled. If multiple batchGroups are submitted the handlers will be called for every batchGroup."
But I am setting the Model to use batch?
Using the model's event handlers doesn't work because they get called for every request that my model make, I only want to handle the specific submitChanges() calls.
Regards
Hi Albert,
as far as I know, the submitChanges sends changes by the setProperty method to the backend. If you call the create function directly for an entity, for which you defined no deferred batch groups, your create operation is sent immediately to the backend. After when calling the submitChanges there will be no callback bacause no changes to submit. You can check for pending changes using method hasPendingChanges method.
Regards
Attila
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Albert,
I think your syntax is wrong.
Please try:
oModel.submitChanges({
success: function(oData){
sap.m.MessageToast.show(oData.toString());
},
error: function(oError) { }
});
Best regards,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Albert,
I guess you have to subscribe to events "requestCompleted" and "requestFailed". As you wrote the events will be fired for every request on your model. So maybe you have to attach the event directly before your request and detaching it directly after recieving the event(s). I tried somehing similar and basically it worked. But for me the "createEntry" and "submitChanges" solution seems to be better (first of all "clearer"). But maybe it´s not possible in your case.
Maybe other experts have a better solution.
Best regards,
Sebastian
Hi,
Yea Unfortunately I have to call the Function Import and the Create method in the same batch. I've tried setting the event handlers and then removing them as soon as they returned something (to stop other calls from interfering) but it unfortunately didn't work as well as I hoped it would.
Thanks again for the reply
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.