cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the newly created entity from backend in SAP Fiori for iOS SDK?

Former Member
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

aschlosser
Employee
Employee
0 Kudos

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

Former Member
0 Kudos

This is exactly what I was asking. I checked and it worked 🙂

Thank you!
Nikola

Answers (0)