on 2025 Apr 09 4:15 PM
Hi CAP experts!
I'm building a Fiori Elements app with a custom action placed in Table toolbar action for the list report, but when I hit the button and inspect the console this error appears:
Uncaught (in promise) Error: Unknown action import
this is the CDS service definition:
service RoyCustDeclMasterDataService {
function pr_roy_cust_decl_report() returns Boolean;
...this the JS implementation:
const cds = require('@sap/cds')
const cdsCompile = require('@sap/cds/lib/compile/cds-compile')
module.exports = cds.service.impl(function() {
this.on('pr_roy_cust_decl_report', async () => {
try {
let dbQuery = 'Call "FL_ROY_CUST_DECL_REPORT_SP"( )'
let result = await cds.run(dbQuery, { })
cds.log().info(result)
return true
} catch (error) {
cds.log().error(error)
return false
}
})
})At this point everything is ok, I'm able to launch the function after cds watch with the URL: .../odata/v4/roy-cust-decl-master-data/pr_roy_cust_decl_report()
now I followed this:
https://sapui5.hana.ondemand.com/sdk/#/topic/7619517a92414e27b71f02094bd08d06
and added in manifest.json:
"content": {
"header": {
"actions": {
"CustomActions": {
"press": "rcd.roycustdeclmdduacus.ext.controller.CustomActions.message",
"visible": true,
"enabled": true,
"text": "Ricalcolo Report"
}
}
}
}and implement CustomActions.js:
sap.ui.define([
"sap/m/MessageBox",
"sap/ui/core/library"
], function(MessageBox, coreLibrary) {
"use strict";
return {
message: async function(oEvent) {
let sActionName = "pr_roy_cust_decl_report";
let mParameters = {
model: this.getModel(),
label: 'Confirm',
invocationGrouping: true
};
this.editFlow.invokeAction(sActionName, mParameters);
}
};
});but when I hit the button and inspect the console this error appears:
Uncaught (in promise) Error: Unknown action import
Any help would be appreciated.
Grazie!
Andrea
Request clarification before answering.
In CustomActions.js#8, the action is named incorrectly. You can see the correct way to name these in the sample in Flexible Programming Model Explorer
examples:
.invokeAction("Service.boundAction"
.invokeAction("Service.EntityContainer/unboundAction"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dinu,
this is the metadata:
<EntityContainer Name="EntityContainer">
<EntitySet Name="Comp_Type" EntityType="RoyCustDeclMasterDataService.Comp_Type">
<NavigationPropertyBinding Path="SiblingEntity" Target="Comp_Type"/>
</EntitySet>
<EntitySet Name="RoyCustDecl_IMP_DUACUS001" EntityType="RoyCustDeclMasterDataService.RoyCustDecl_IMP_DUACUS001">
<NavigationPropertyBinding Path="SiblingEntity" Target="RoyCustDecl_IMP_DUACUS001"/>
</EntitySet>
<FunctionImport Name="pr_roy_cust_decl_report" Function="RoyCustDeclMasterDataService.pr_roy_cust_decl_report"/>
</EntityContainer>I changed the CustomActions.js in this way:
sap.ui.define([
"sap/m/MessageBox",
"sap/ui/core/library"
], function(MessageBox, coreLibrary) {
"use strict";
return {
message: function(oEvent) {
let sActionName = "RoyCustDeclMasterDataService.EntityContainer/pr_roy_cust_decl_report";
let mParameters = {
model: this.getModel(),
label: 'Confirm',
invocationGrouping: true,
requiresNavigation: true,
isNavigable: true,
};
this.editFlow.invokeAction(sActionName, mParameters);
}
};
});but the error is always the same: "Unknown action import"
Any advice?
Thanks
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.