Skip to Content
avatar image
Former Member

oData v2 submitChanges Error Handling

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.ODataModel

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 16, 2015 at 11:14 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Albert,

      I just came accross method attachEventOnce. It´s a member of object sap.ui.base.EventProvider and ODataModel object is an indirect subclass of this. So it should work on principle. I didn´t tested it but maybe this could solve your issue?

      Best regards, Sebastian

  • May 14, 2016 at 09:09 AM

    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

    Add comment
    10|10000 characters needed characters exceeded