on 05-07-2018 3:06 PM
Hi everyone,
I am trying to get the newly created entity in the backend as a result, but I cannot find anything in the documentation. Does anyone know if this is possible or not implemented at all. The OData service responds with the newly created entity.
This is the method in question: https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/Latest/en-US/Documents/Frameworks/SAPOData...
And a code sample would look something like this:
@objc func createEntity() {
self.showFioriLoadingIndicator()
self.view.endEditing(true)
self.logger.info("Creating entity in backend.")
self.zfsmobilesrvEntities.createEntity(self.entity) { error in
self.hideFioriLoadingIndicator()
if let error = error {
self.logger.error("Create entry failed. Error: \(error)", error: error)
let alertController = UIAlertController(title: NSLocalizedString("keyErrorEntityCreationTitle", value: "Create entry failed", comment: "XTIT: Title of alert message about entity creation error."), message: error.localizedDescription, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: self.okTitle, style: .default))
OperationQueue.main.addOperation({
// Present the alertController
self.present(alertController, animated: true)
})
return
}
self.logger.info("Create entry finished successfully.")
OperationQueue.main.addOperation({
self.dismiss(animated: true) {
FUIToastMessage.show(message: NSLocalizedString("keyEntityCreationBody", value: "Created", comment: "XMSG: Title of alert message about successful entity creation."))
self.tableUpdater?.entitySetHasChanged()
}
})
}
}
Basically, in the line of a successful creation of an entry, I would like to know if there is a way to also get the new entity as an object.
Thank you in advance!
Nikola,
This is maybe simpler than you expected - or I'm misunderstanding. If you call `createEntity(self.entity)`, the `self.entity` will be updated with the latest server version that you have after the create, i.e. all properties will be updated with the response from the create operation.
Thanks
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.