2024 Apr 15 2:37 PM - edited 2024 Apr 16 10:58 AM
Hi everyone,
we have a problem with Fiori elements resp. Flexible Programming Model and invoking a custom static action from RAP service.
We struggle with the invokeAction function of EditFlow. We have an EntitySet Whitelist and an static action deleteAll defined in RAP. So this action refers to the complete collection of Whitelist EntitySet. But now we are not able to invoke the action for the whole EntitySet. API (https://sapui5.hana.ondemand.com/sdk/#/api/sap.fe.core.controllerextensions.EditFlow%23methods/invok... ) says that we need to handover parameter model for unbound actions or parameter contexts for bound actions. I would suggest an static action is an unbound action, as not bound to any specific entity. But in our metadata it says:
The controller says cannot find action deleteAll if we try as unbound action with model, logic when the metadata says it is bound. But if we provide an context the action is called for that entity(s) from the context(s), which is not working as it is defined as static action to delete all entities. If we try with an empty array for contexts the console says that we need to define an context for bound actions or a model for unbound actions.
How do we have to invoke the action? If we use the action like standard elements action behind an button it's working just fine, just our custom call is not working as exspected - so I assume it's a frontend problem and not backend.
Any help/suggestion is appreciated! Thanks,
Tina
SAP Fiori Elements SAPUI5 ABAP RESTful Application Programming Model SAP Cloud Application Programming Model
We solved it with the following coding:
// Get controlId from table annotations
const oViewContent = this.getEditFlow().getView().getAggregation("content");
const oTableDefinition = oViewContent[0].getAggregation("content").getTableDefinition()
const sControlId = oTableDefinition.annotation.id; // "fe::table::ZBC_C_ACI_WHITELIST::LineItem"
this.editFlow.invokeAction("com.sap.gateway.srvd.zbc_aci_whitelist_srv.v0001.deleteAll()", {
//contexts: aSelectedContexts[0], - not needed for static action
//model: oDataModel, - not needed for static action
controlId: sControlId, // needed for static action
bStaticAction: true // needed for static action
}).then(function () {
MessageToast.show(oResourceBundle.getText("tableContentDeleted"));
this.refresh(); // Refresh table
}.bind(this));
Found it with debugging a standard elements action call for the same static action. This is not in the documentation (API Reference - Demo Kit - SAPUI5 SDK (ondemand.com)) and might change in future! Currently we are using UI5 version 1.120.x
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to your code, I was also able to successfully invoke a static action RAP, and I'm using version 1.120 as well.
I don't understand how it's possible that this isn't documented—I thought I might have been doing something wrong, but it seems like we're in the same situation.
I hope there won't be any future changes that could break the development. Have you done any further research on this topic since April? Thanks!
User | Count |
---|---|
68 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.