Odata.v4.OdataModel - hasPendingChnages error after failed submitChanges
See original GitHub issueI use Odata V4 and I check if submitBatch method has been failed by checking the result of hasPendingChanges method.
this.getModel().submitBatch(BATCH_ID).then(function () {
var bHasErrors = this.getModel().hasPendingChanges(BATCH_ID);
if (bHasErrors) {
this._displayError();
} else {
...
}.bind(this)).catch(function () {
...
}.bind(this));
},
If the result of hasPendingChanges is true, then batch failed(f.e. ‘such value already exists in database’) and error message appears. But after fixing duplicated value and resubmit the same error occurs.
The same issue described on SAP tutorials GitHub page, but it is still in process…
I tried to delete my batches(sGroupId = “TaskDetailBatch”) with array of bathes, but this array always updates the previous condition:
P.S. The same isue was not resolved here
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
sap.ui.model.odata.v4.ODataModel - API Reference - Demo Kit
Valid values are 'API', 'Auto', 'Direct' see sap.ui.model.odata.v4. ... If a back-end request fails, the 'dataReceived' event provides an Error in the ...
Read more >Creating an Entity
As long as the list binding has a transient entity, ODataListBinding#hasPendingChanges returns true and the following methods of ODataListBinding raise an error ......
Read more >oData Model submitChanges error callback function not ...
I would like to know when I use the submitChanges of sap.ui.model.odata.v2.ODataModel , and have a success and error callback function.
Read more >SAPUI5 for dummies part 5: A complete step-by-step exercise
Update OData model record. Here comes the core part of our exercise. When the user clicks the Save button we're going to execute...
Read more >[SAPUI5] Get and set properties of a binded model and submit ...
hasPendingChanges ( ) ) {. MessageToast . show ( "Nothing to do!" ) return. } // Now submit your changes. oModel . submitChanges...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @YahorStsefanovich ,
I do not get why you need another updateGroupId. I would expect something like the following: Create case
resetChanges
would act globally on all changes.)Edit case
Using several updateGroupIds does not seem like a good idea. Changes in different updateGroups lead to several batch requests. Is this really intended?
Best regards Mathias.
Hi @YahorStsefanovich ,
I guess @vfweiss has already provided a possible solution for the create scenario.
In general, the promise of submitBatch is only rejected if the batch request itself has failed. The consequence is that this promise does not tell if changes were successfully persisted in the backend. However, it provides the point in time when an application could check itself.
hasPendingChanges
, which exists at context, binding and model with the respective scope, is one option.I am not sure I understood your case correctly. You are trying to delete a number of records? What is the purpose of putting them into different batch requests?
Let me add two comments:
Changing requests are sent in changesets within the batch request. A changeset represents a logical unit of work and is either persisted as a whole or not at all. So far, changing requests are typically put into the same one changeset by the V4 model. Furthermore, the processing of the batch request will stop once a request has failed. (The preference continue-on-error is not used by the V4 model. Also it must not be used when using v4.Context#requestSideEffects.)
With a backend that provides language dependent, understandable messages, see also Server Messages in OData V4 Model, it should be sufficient to display the messages from the message model to the user. It would then not be required to understand in application code what failed but only that the save was not successful.
Best regards Mathias.