cancel
Showing results for 
Search instead for 
Did you mean: 

OData submitChanges() Error Handling

Former Member
0 Kudos

Hello,

I'm using OData Model with TwoWay binding and after I change something I call the method submitChanges().

I'm expecting an error because of the eTag verification.

The problem is that the error occur but the callback function is always success.

If you open the OData object, you will see the expected error response 412, but it is considered success in general.

I want to show a MessageBox when this error occurs, but the response is always success even with this error.

Hou can I proceed?

Thanks in advance,

Henrique Schorr

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Henrique,

I have the exact same problem. Did you solve this issue in meantime? My submitChanges always result in executing the 'success' callback function.

Kind Regards,

Nico van der Linden

Former Member
0 Kudos

Hello Nico,

No one answered and I was unable to find a default solution. So here it is what I did:

A loop in the batchResponse looking for errors.

for (var i = 0; i < oData.__batchResponses.length; i++) {

       oResponse = oData.__batchResponses[i].response;

       if (typeof oResponse !== "undefined" && oResponse.statusCode === "412") {

            this.showDataInconsistency();

            break;

       }

}

Best regards,

Henrique Schorr

Ryan-Crosby
Active Contributor
0 Kudos

Hi,

I have had to do the same in a batch request example and did something similar to Henrique's approach.

Regards,

Ryan Crosby

Former Member
0 Kudos

Hi Henrique,

Thanks for your reply, in meantime I indeed did something similar. And it seems to work for me as well.

I get a __batchResponses array back through the 'success' call back function of submitChanges which always contains two entries. __batchResonses[0] contains the error (if there was an error) and __batchResponses[1] is always correct.

Did you have the same finding? I started with a for loop as well but since I noticed that the error response is always in the first array item I just looked directly for an undefined or response Higher then 299 to be sure that an error occurred.

Regards,

Nico