cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori Elements: Call invokeActions via ExtensionAPI and oData v4

0 Kudos

Hello,

In my CAP project I have added a custom action using extension points like here.

My intention is to collect the SelectedContext and then invoke an action that is defined at the service level. In oData v2, the ExtensionAPI has a method called invokeAction, but in oData v4 it doesn't exist.

Is there a way to call the action from the extension controller with oData v4?

Thanks.

gregorw
Active Contributor

You should add the Tag "Fiori Elements" as this is not a CAP issue.

0 Kudos

I found the way: via editFlow for V4 but I still have a problem. The action is unbound, so the context parameter has to be null. The question is: What parameters does the invokeAction expect? Are these parameters in the service req? I need them in the service so I can work with them...

At the moment, I pass an object like this as a parameter: {"selectedItems": [{ItemID: "001"}, {ItemID: "003"}]}. It gives me an error: cannot read position 0 of undefined. So I guess invokeAction doesn't expect this kind of object...

Thanks.

former_member729305
Participant
0 Kudos

Dear didac_casanovas52,

I am currently also trying to connect to my custom action on service.cds layer from my ui5 fiori elements extension point. Therefore I consider your approach but I am not yet sure how to implement it. Do you perhaps have an easy example to post here?

Best Regards

View Entire Topic
SchiwekM
Advisor
Advisor
0 Kudos

Hello,

if the issue still exists:

invokeAction can be used since fall via the extension of the editFlow API of V4.

An easy example is available in the Fiori elements V4 feature showcase: GitHub - SAP-samples/fiori-elements-feature-showcase: Sample application that demonstrates and docum...

As stated in the documentation (API Reference - Demo Kit - SAPUI5 SDK (ondemand.com)) for unbound actions the model parameter is mandatory.

Best regards,

Marten

0 Kudos

Hey Marten,

i´m trying to invoke action, but parameters "skipParameterDialog" and also "parameterValues" are ignored. Am i doing something wrong ?

Based on https://sapui5.hana.ondemand.com/sdk/#/api/sap.fe.core.controllerextensions.EditFlow%23methods/invok...

Its not CAP, but ABAP RAP, on-premise S4HANA, UI5 version 1.102.8", ODATA V4, action parameters done by CDS Abstract Entity.

Extension controller method:

test_function: function (oContext, aSelectedContexts) {
this.editFlow.invokeAction("com.sap.gateway.srvd.zre_vazby_hr_nj_osoba_vazba.v0001.zmenit_vazbu(com.sap.gateway.srvd.zre_vazby_hr_nj_osoba_vazba.v0001.VazbaType)", {
contexts: aSelectedContexts[0],
invocationGrouping: "Isolated",
label: "test",
parameterValues: [{ name: "VZTAH_OS", value: "UŽIVATEL" },
{ name: "CPRAC", value: "1" },
{ name: "begdat", value: "20221212" },
{ name: "enddat", value: "20221212" }
],
requiresNavigation: false,
skipParameterDialog: false
})
},

I done little bit research in UI5 library, but i think there is a constant for "showActionParameterDialog" instead of taking variable. Also in object "mParameters", array/map "parameterValues" is not passed to function "callBoundAction".

Is this a bug ?

callBoundAction scope, no array/map "parameterValues" in "mParameters"

SchiwekM
Advisor
Advisor
0 Kudos

Hi Marek,

please have a look at the respective API Documentation for 1.102.3: API Reference - Demo Kit - SAPUI5 SDK (ondemand.com)

The mentioned parameters were added in a newer release. With the latest S4 On-Prem Update, which should bump the UI5 Version to 1.108, you should be able to use them: API Reference - Demo Kit - SAPUI5 SDK (ondemand.com).

Best regards & Happy Holidays,

Marten

0 Kudos

Versions, right. Thank you, Marten. Happy Holidays aswell.

Btw. just a side note, maybe "Since: X.XX version" note would be helpfull, like e.g. in sap.m.Table properties.

mantri_sagar
Explorer
0 Kudos

Hi smarten,

Please provide some sample code to call parameterized unbound action using invoke action and refresh list afterward. Since this is not possible though side effects similar to bound action looking for some alternative way to achieve this requirement.

SchiwekM
Advisor
Advisor
0 Kudos

Hi 03e8435650854b0dbc2fe52f17eae075,

please consider bound actions, which are bound against the collection (Definition Language (CDL) | CAPire (cloud.sap)). Those behave like unbound actions on the UI, but with the distinction, that you still have an entity collection context and can use SideEffects.

{ $Type : 'UI.DataFieldForAction', Action : 'Service.action(Service.YourEntity)', Label : 'My bound collection action', },

Hope that already helps & BR,

Marten

Richie
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Marten, Do you know for sure if this supports both actions and functions? I can get it to work with actions, but have no luck with functions so far. The fact that the method is named invoke functions seems to be it is only for actions?