cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Offline Store Update Issue for Android Platform

former_member337066
Participant
801

error2.png

Hello Experts,

We are working on Offline Application for Android Platform. When we are updating any existing record in offline store that time we are getting

Error:value":"[-10128] The request on an entity failed because its etag did not match the request's conditions.

We are using below code for updating the record in offline

sap.OData.applyHttpClient();

oModel.update("MobCodeSet(OrderNo='5183819')", postEntry, null,

function(){

console.log(success);

}, function(error) {

console.log(error);

}, true);

Please find the attached screenshot for error.

Can you please suggest where we are going wrong.

Regards,

Ashish

View Entire Topic
EdwarSoto
Participant
0 Likes

Hello, I solved the problem this way. According to the documentation I found in this link,

https://help.sap.com/doc/d9c75eebcfa840c8a4aa4b0e6a8136de/3.0.15/en-US/e5033aa25c67486ab06505f565bf6...

It says that we must send the same eTag to the entity to be able to update.

Then... I did a read before updating and copy etag property from metadata of old record.

this.oModel = this.getView().getModel(); 
var that = this;
that.oModel.read(vPathCero, {
     success: function (oData, response) {
		that.oModel.update(vPathCero, myEntity, {
		     success: function (oData, response) {
                         // your code on success update
                     },
		     error: function (oError) {
                       // your code on error update
                     },
//////////////////////////////////////////////////////////                 
		    "eTag": oData.__metadata.etag
//////////////////////////////////////////////////////////
               });
      },
    error: function (oError) { 
    // your code on error read
   }
 });