SAP-samples / fiori-elements-feature-showcase

Sample application that demonstrates and documents a broad variety of features of SAP Fiori elements for OData V4. Developers can play around with the new features and learn how to implement them.
https://community.sap.com/topics/fiori-elements
Apache License 2.0
217 stars 74 forks source link

invokeAction - error handling and results #14

Closed wozjac closed 1 year ago

wozjac commented 1 year ago

Hello,

Scenario 1

  1. CAP V4 service with an action with 3 parameters. The implementation checks the parameters, if invalid it throws an error.
  2. This action is added to the List page, in the table toolbar
    "targets": {
        "MyListPage": {
          "type": "Component",
          "id": "MyListPage",
          "name": "sap.fe.templates.ListReport",
          "options": {
            "settings": {
              "entitySet": "MyEntitySet",
              "variantManagement": "Page",
              "hideFilterBar": true,
              "navigation": {
                ...
              },
              "controlConfiguration": {
                "@com.sap.vocabularies.UI.v1.LineItem": {
                  "actions": {
                    "CustomAction": {
                      "press": "my.custom.action",
                      "text": "Some Text",
                      "enabled": true,
                      "visible": true
                    }
                  }
                }
  3. The controller extends ControllerExtension, invokes action passing only the model (unbound action).
...
let parameters = {
   model: this.base.editFlow.getView().getModel(),
    label: "Confirm",
};
this.base.editFlow.invokeAction(actionName, parameters)
  1. If the backend responds with an error, no error dialog shown in the ui, dumps on operations.js. error

Scenario 2

  1. The same action responds with req.reply passing a result object.
  2. invokeAction.then((res) => { }) function does not receive it (res is undefined)?

BR, Jacek

schiwekM commented 1 year ago

Hi @wozjac,

thanks for using the feature showcase.

Both issues should be fixed with UI5 Version 1.110.0 coming most likely next week / the week after.

Please excuse any issues. Scenario two was a limitation for unbound actions, for bound actions it should already work.

If you have to use a previous UI5 version you can fallback to the UI5 default: https://sapui5.hana.ondemand.com/#/topic/b54f7895b7594c61a83fa7257fa9d13f and the result will be available through the bound context of the operation.

Example:

const oOperation = this.base.getModel().bindContext('/unboundAction(...)')

        oOperation
          .setParameter('param1', 'value 1')
          .setParameter('param2', 'value 2')
          .setParameter('param3', 'value 3')
          .execute()
          .then(
            function () {
              //some logic
            }.bind(this),
            function (oError) {
              MessageBox.error(oError.message)
            }
          )

Hope that helps & BR, Marten

wozjac commented 1 year ago

Thanks for explanation!

gregorwolf commented 1 year ago

Hi @schiwekM,

is that also an issue in 1.108 LTS release? Will it be patched also there?