Skip to Content

UI5 OData Remove/Delete callback

Nov 11, 2016 at 04:45 PM


avatar image

Hi Gurus,

i'm facing a little problem during the implementation of Remove method for OData models

i implemented the following code and if everything is succesful the callback is triggered.

Sadly, when something wrong occurs (i.e. i get a 400 or a 500 response), the error callback is not triggered at all

 var oModel = new sap.ui.model.odata.v2.ODataModel(
         self.BASE_URL + serviceName + "/",
           user: self.user,
           password: self.password,
           headers: headers
       oModel.attachMetadataFailed(null, function(){
           var resp  = {
             status: 418,
             message: "Error in retreiving model metadata"
       oModel.attachMetadataLoaded(null, function(){
         var callbacks = {
           success: function (oData, oResponse) {
           error: function (oResponse) {

var uri = "/" + entityName + ("(" + id + ")");
         oModel.remove(uri, item, callbacks);
 }, null);

Do you have any idea about why it's wrong?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Simone Milesi Nov 14, 2016 at 07:48 AM

My shame.

The call was dynamic (for Create/Update/Delete) so i always passed even the Object.

Delete does not want it.

10 |10000 characters needed characters left characters exceeded
Nils Lutz Nov 12, 2016 at 09:04 AM

if im not wrong you only catch errors on failed metadata loaded. you have to implement own callbacks for the odata remove function.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

No, if metadata are loaded (so the connection is ok and the model is created), i fill callbacks variable which stores the 2 functions SUCCESS and ERROR.

In fact, as i stated, in case of successful deletion, the SUCCESS callback, created this way, is triggered.