cancel
Showing results for 
Search instead for 
Did you mean: 

ODATA Model Remove method success callback function not passing oData object.

Former Member
0 Kudos

Hi, As per the API documentation, oData remove method success callback function should send an argument oData, but its coming as undefined and also can you please help me with "is it possible to pass additional arguments to callback function"?


  deleteProduct:function(oEvent){

var sPath=oEvent.getSource().getBindingContext().getPath();

this.getModel().remove(sPath, {

context:sPath,

success:this._onDelSucc.bind(this),

error:this._onDelFail.bind(this)

} );

},

_onDelSucc:function(oData,response){

//OData object value is coming as undefined.

//MessageToast.show("product "+response.requestUri.split("('")[1].replace("')","")+" deleted " );

},

_onDelFail:function( ){

MessageToast.show("product can't be deleted " );

}

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks.

passing message as an additional argument is worked.

Still not able to figure out why oData argument is coming as undefined.

deleteProduct:function(oEvent){

    var prodId = oEvent.getSource().getBindingContext().getProperty("ProductID");

    var prodName = oEvent.getSource().getBindingContext().getProperty("Name");

    var sMsg ="Product "+ prodId+"("+ prodName +") deleted";

   var sPath=oEvent.getSource().getBindingContext().getPath();

   this.getModel().remove(sPath,

    {context:sPath, success:this._onDelSucc.bind(this,sMsg),error:this._onDelFail.bind(this)}

   );

  },

     _onDelSucc:function(sMsg,oData,response){

     MessageToast.show(sMsg);

  },

saurabh_vakil
Active Contributor
0 Kudos

In the deleteProduct(oEvent) function you can retrieve the product id from the oEvent parameter and store it in a variable. Then in the success callback function you can use this variable to display which product was deleted.

Former Member
0 Kudos

Saurubh,

I can do that, my question is why the oData argument in success call back is coming as undefined.

and also I can only use local variable to inline execution of callback, but if the function is outside the delete product closure like code pasted, I must use global which I don't want.

Regards,

Nagaraju

former_member203031
Contributor
0 Kudos

Hi NagaRaju,

please check the remove method in the below piece of code:

oModel.remove('/Products(1)', null,

function()

{

  alert("Delete successful");

  },

function()

{

alert("Delete failed");

}

);

in the function() you can pass the parameters.

for the brief info please click the below link:

UI Development Toolkit for HTML5 (SAPUI5) - SAP Library

You will some more info regarding this.

Thanks,

Deepak Raj.

Former Member
0 Kudos

Hi Deepak,

I already went through these documents,

My question is why oData(callback argument) is undefined.

former_member203031
Contributor
0 Kudos

Could you please check once in sap gateway client after removing item.

what is the response you are getting there?

Former Member
0 Kudos

Response 204.

I can capture this thorugh response argument from success callback function.