{"action":"created","issue":{"url":"https://api.github.com/repos/SAP/openui5/issues/627","labels_url":"https://api.github.com/repos/SAP/openui5/issues/627/labels{/name}","comments_url":"https://api.github.com/repos/SAP/openui5/issues/627/comments","events_url":"https://api.github.com/repos/SAP/openui5/issues/627/events","html_url":"https://github.com/SAP/openui5/issues/627","id":109999873,"number":627,"title":"OData: submitChanges for creates","user":{"login":"themasch","id":170171,"avatar_url":"https://avatars.githubusercontent.com/u/170171?v=3","gravatar_id":"","url":"https://api.github.com/users/themasch","html_url":"https://github.com/themasch","followers_url":"https://api.github.com/users/themasch/followers","following_url":"https://api.github.com/users/themasch/following{/other_user}","gists_url":"https://api.github.com/users/themasch/gists{/gist_id}","starred_url":"https://api.github.com/users/themasch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themasch/subscriptions","organizations_url":"https://api.github.com/users/themasch/orgs","repos_url":"https://api.github.com/users/themasch/repos","events_url":"https://api.github.com/users/themasch/events{/privacy}","received_events_url":"https://api.github.com/users/themasch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T12:44:13Z","updated_at":"2015-10-12T08:57:30Z","closed_at":null,"body":"Again I don't have a minimal example for this problem but some references to the code. Sorry for that :disappointed:. \r\nWe're having an issue with submitChanges() to submit an entity created with createEntry(). \r\nWhen the first request is successful, everything works fine. The Context is updated, mChangedEntities is updated, hasPendingChanges returns false afterwards. \r\n\r\nThe problems start to happen when the first request fails. The user may have entered an invalid value, the backend responds with a HTTP 400 and some error messages. The user fixes his error, clicks \"save\" again. A new submitChanges() is triggerd. It creates a new request that does NOT contain a reference to the context created by createEntry() (because that gets assigned by createEntry). That way, the - now successful - response does not update the context nor mChangedEntities and by this, hasPendingChanges() returns true although the POST-Request went well. \r\n\r\nThis happens with useBatch=true and useBatch=false, no difference. \r\n\r\nHas someone already solved that problem? Are we doing something wrong? \r\nHere is roughly what we are doing: \r\n```\r\nonSave: function() {\r\n    if(oModel.hasPendingChanges()) {\r\n        oModel.submitChanges()\r\n            .then(function() {\r\n                if(this.oNewCtx) {\r\n                    this.navTo(\"details\", { id: this.oNewCtx.getPath() })\r\n                }\r\n            }).catch(console.error.bind(console));\r\n    } \r\n}, \r\nonNewDetail: function() {\r\n    this.oNewCtx = oModel.createEntry(\"/Collection\", ..);\r\n    oView.setBindingContext(this.oNewCtx);\r\n},\r\nonChangeDetail: function() {\r\n    if(oModel.hasPendingChanges()) {\r\n        MessageBox.show(\"You have unsaved changes!\");\r\n        return;\r\n    }\r\n    // change binding here...\r\n},\r\nonBack: function() {\r\n    oModel.resetChanges();\r\n    this.navTo(\"somewhere far far away\");\r\n}\r\n```\r\n\r\nSo we currently depend on hasPendingChanges() to check if the changed/created entity has unsaved changes. This works for updates & \"perfect\" creates but failes only for the case described above. "},"comment":{"url":"https://api.github.com/repos/SAP/openui5/issues/comments/147334710","html_url":"https://github.com/SAP/openui5/issues/627#issuecomment-147334710","issue_url":"https://api.github.com/repos/SAP/openui5/issues/627","id":147334710,"user":{"login":"matz3","id":1410947,"avatar_url":"https://avatars.githubusercontent.com/u/1410947?v=3","gravatar_id":"","url":"https://api.github.com/users/matz3","html_url":"https://github.com/matz3","followers_url":"https://api.github.com/users/matz3/followers","following_url":"https://api.github.com/users/matz3/following{/other_user}","gists_url":"https://api.github.com/users/matz3/gists{/gist_id}","starred_url":"https://api.github.com/users/matz3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matz3/subscriptions","organizations_url":"https://api.github.com/users/matz3/orgs","repos_url":"https://api.github.com/users/matz3/repos","events_url":"https://api.github.com/users/matz3/events{/privacy}","received_events_url":"https://api.github.com/users/matz3/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T08:57:30Z","updated_at":"2015-10-12T08:57:30Z","body":"f75e47dfb0d7e2fdd2389ba486af6b2fe7744261 seems to be related to this issue.\r\n@loginger can you have a look if your change should solve this?"}}