cancel
Showing results for 
Search instead for 
Did you mean: 

Add a custom action button to table toolbar object page in CAP CDS Annotations OData v2

ClaudioBanfi
Explorer
0 Kudos

Hello everyone,

I have to add a custom button in a table toolbar of object page, but the button does not appear.

With cds annotations I try to add an other action as inline button and as table toolbar action. It works fine, but it's not what I need.

It is an OData v2 app.

This is the Manifest.json, I add the action in the extension controller how explain in sap documentation

{
"_version": "1.29.0",
"sap.app": {
"id": "relazioniindustriali",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"resources": "resources.json",
"ach": "ach",
"dataSources": {
"mainService": {
"uri": "v2/browse",
"type": "OData",
"settings": {
"annotations": ["annotation"],
"localUri": "localService/metadata.xml"
}
},
"annotation": {
"type": "ODataAnnotation",
"uri": "annotations/annotation.xml",
"settings": {
"localUri": "annotations/annotation.xml"
}
}
},
"offline": false,
"sourceTemplate": {
"id": "ui5template.smartTemplate",
"version": "1.40.12"
},
"crossNavigation": {
"inbounds": {
"intent1": {
"signature": {
"parameters": {},
"additionalParameters": "allowed"
},
"semanticObject": "Bacheca",
"action": "Browse",
"title": "{{tileTitle}}",
"subTitle": "{{tileSubtitle}}",
"info": "{{appDescription}}",
"icon": "sap-icon://notification-2"
}
}
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "sap-icon://task",
"favIcon": "images/favicon.ico",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
},
"supportedThemes": ["sap_hcb", "sap_belize", "sap_fiori_3", "sap_bluecrystal"]
},
"sap.ui5": {
"resources": {
"js": [],
"css": []
},
"dependencies": {
"minUI5Version": "1.65.0",
"libs": {
"sap.ui.core": {
"lazy": false
},
"sap.ui.generic.app": {
"lazy": false
},
"sap.suite.ui.generic.template": {
"lazy": false
}
},
"components": {}
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"@i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/i18n.properties"
},
"i18n|sap.suite.ui.generic.template.ListReport|Pubblications": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/ListReport/Pubblications/i18n.properties"
},
"i18n|sap.suite.ui.generic.template.ObjectPage|Pubblications": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/ObjectPage/Pubblications/i18n.properties"
},

"i18n|sap.suite.ui.generic.template.ObjectPage|Attachments": {
"type": "sap.ui.model.resource.ResourceModel",
"uri": "i18n/ObjectPage/Attachments/i18n.properties"
},

"": {
"dataSource": "mainService",
"preload": true,
"settings": {
"defaultBindingMode": "TwoWay",
"defaultCountMode": "Inline",
"refreshAfterChange": false,
"metadataUrlParams": {
"sap-value-list": "none"
}
}
}
},
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ObjectPage.view.Details#relazioniindustriali::sap.suite.ui.generic.template.ObjectPage.view.Details:: Attachments": {
"controllerName": "relazioniindustriali.ext.controller.AttachmentDownload",
"sap.ui.generic.app": {
"Attachments": {
"EntitySet": "Attachments",
"Sections": {
"attachment::com.sap.vocabularies.UI.v1.LineItem": {
"id": "attachment::com.sap.vocabularies.UI.v1.LineItem",
"Actions": {
"downloadFileFromFN": {
"id" : "downloadFileFromFN",
"text" : "Scarica il file",
"press" : "relazioniindustriali.ext.controller.AttachmentDownload.downloadFileFromFN",
"requiresSelection": true
}
}
}
}
}
}
}
}
}
},
"contentDensities": {
"compact": true,
"cozy": true
}
},
"sap.ui.generic.app": {
"_version": "1.3.0",
"settings": {
"forceGlobalRefresh": false,
"objectPageHeaderType": "Dynamic",
"showDraftToggle": false
},
"pages": {
"ListReport|Pubblications": {
"entitySet": "Pubblications",
"component": {
"name": "sap.suite.ui.generic.template.ListReport",
"list": true,
"settings": {
"filterSettings": {
"useDateRange": true
},
"tableSettings": {
"type": "ResponsiveTable"
},
"condensedTableLayout": true,
"smartVariantManagement": true,
"variantManagementHidden": true,
"enableTableFilterInPageVariant": true,
"quickVariantSelectionX": {
"showCounts": false,
"enableAutoBinding": true,
"variants": {
"0": {
"key": "v0",
"entitySet": "Pubblications",
"annotationPath": "com.sap.vocabularies.UI.v1.SelectionVariant#Tutte"
},
"1": {
"key": "v1",
"entitySet": "Pubblications",
"annotationPath": "com.sap.vocabularies.UI.v1.SelectionVariant#Comunicazioni"
},
"2": {
"key": "v2",
"entitySet": "Pubblications",
"annotationPath": "com.sap.vocabularies.UI.v1.SelectionVariant#Accordi"
}
}
}
}
},
"pages": {
"ObjectPage|Pubblications": {
"entitySet": "Pubblications",
"defaultLayoutTypeIfExternalNavigation": "MidColumnFullScreen",
"component": {
"name": "sap.suite.ui.generic.template.ObjectPage",
"settings": {
"sections": {
"attachment::com.sap.vocabularies.UI.v1.LineItem": {
"EntitySet": "Attachments",
"Sections": {
"tableSettings": {
"type":"ResponsiveTable",
"multiSelect": false
}
}
}
}
}
}
}
}
}
}
},
"sap.platform.abap": {
"uri": ""
},
"sap.fiori": {
"registrationIds": [],
"archeType": "transactional"
},
"sap.platform.hcp": {
"uri": ""
},
"sap.cloud": {
"service": "sf_relazioni_industriali.service"
}
}
This is cds annotations
using {PubblicationService} from '../../srv/user-service';

annotate PubblicationService.Pubblications with @odata.draft.enabled : false;
annotate PubblicationService.Pubblications with @fiori.draft.enabled : false;

annotate PubblicationService.Pubblications with @(UI : {
Identification : [{
$Type : 'UI.DataField',
Value : title
}],
HeaderInfo : {
$Type : 'UI.HeaderInfoType',
TypeName : '{i18n>pubblication}',
TypeNamePlural : '{i18n>pubblicationPlural}',
Title : {
$Type : 'UI.DataField',
Value : title,
}
},
SelectionFields : [
originalDate,
area_id
],
LineItem : [
{
$Type : 'UI.DataField',
Value : iconUrl,
![@UI.Importance] : #High,
},
{
$Type : 'UI.DataField',
Value : title,
},
{
$Type : 'UI.DataField',
Value : type.name,
},
{
$Type : 'UI.DataField',
Value : area.name,
},
{
$Type : 'UI.DataField',
Value : originalDate,
},
],
FieldGroup #Description : {
$Type : 'UI.FieldGroupType',
Data : [{
$Type : 'UI.DataField',
Value : description,
}, ]
},
FieldGroup #Details : {
$Type : 'UI.FieldGroupType',
Data : [
{
$Type : 'UI.DataField',
Value : areaName,
},
{
$Type : 'UI.DataField',
Value : type_code
},
{
$Type : 'UI.DataField',
Value : originalDate
},
],
},
Facets : [
{
$Type : 'UI.CollectionFacet',
Label : '{i18n>pubblicationDetails}',
Facets : [
{
$Type : 'UI.ReferenceFacet',
Target : '@UI.FieldGroup#Description',
},
{
$Type : 'UI.ReferenceFacet',
Target : '@UI.FieldGroup#Details',
},
],
},
{
$Type : 'UI.ReferenceFacet',
Target : 'attachment/@UI.LineItem',
Label : '{i18n>attachmentList}'
},
],
SelectionVariant #Comunicazioni : {
$Type : 'UI.SelectionVariantType',
Text : '{i18n>selVarComunicazioni}',
SelectOptions : [{
$Type : 'UI.SelectOptionType',
PropertyName : type_code,
Ranges : [{
$Type : 'UI.SelectionRangeType',
Sign : #I,
Option : #EQ,
Low : '2',
}, ],
}, ]
},
SelectionVariant #Accordi : {
$Type : 'UI.SelectionVariantType',
Text : '{i18n>selVarAccordi}',
SelectOptions : [{
$Type : 'UI.SelectOptionType',
PropertyName : type_code,
Ranges : [{
$Type : 'UI.SelectionRangeType',
Sign : #I,
Option : #EQ,
Low : '1',
}, ],
}, ]
},
SelectionVariant #Tutte : {
$Type : 'UI.SelectionVariantType',
Text : '{i18n>selVarTutti}',
SelectOptions : [{
$Type : 'UI.SelectOptionType',
PropertyName : type_code,
Ranges : [{
$Type : 'UI.SelectionRangeType',
Sign : #I,
Option : #BT,
Low : '1',
High : '2',
}],
}, ]
},
PresentationVariant : {
$Type : 'UI.PresentationVariantType',
SortOrder : [
{
$Type : 'Common.SortOrderType',
Property : modifiedAt,
Descending : true,
}, ],
},
}) {
notifyUsers @UI.Hidden;
title @title : '{i18n>pubblicationTitle}';
originalDate @title : '{i18n>originalDate}';
areaName @title : '{i18n>validFor}';
area_id @title : '{i18n>validFor}';
area @Common.ValueList : {
$Type : 'Common.ValueListType',
CollectionPath : 'Areas',
SearchSupported : true,
Parameters : [
{
$Type : 'Common.ValueListParameterOut',
LocalDataProperty : area_id,
ValueListProperty : 'id',
},
{
$Type : 'Common.ValueListParameterDisplayOnly',
ValueListProperty : 'name',
},
],
} @Common.ValueListWithFixedValues : true @title : '{i18n>validFor}';
description @UI.MultiLineText @title : '{i18n>description}';
iconUrl @UI.IsImageURL;
type @title : '{i18n>pubblicationType}' @Common : {
Text : type.name,
TextArrangement : #TextOnly
};
}

annotate PubblicationService.Areas with @(
UI.Identification : [{
$Type : 'UI.DataField',
Value : name
}],
UI.SelectionFields : [name],
) {
id @Common : {
Text : name,
TextArrangement : #TextOnly
};
name @title : '{i18n>assignedArea}'
}

annotate PubblicationService.Attachments with @(UI : {
Identification : [
{
$Type : 'UI.DataField',
Value : ID,
},
{
$Type : 'UI.DataField',
Value : name
}
],
HeaderInfo : {
$Type : 'UI.HeaderInfoType',
TypeName : '{i18n>attachmentType}',
TypeNamePlural : '{i18n>attachmentTypePlural}',
Title : {
$Type : 'UI.DataField',
Value : name,
},
},
LineItem : [
{
$Type : 'UI.DataFieldWithUrl',
Value : name,
UrlContentType : mimeType,
Url : attachmentUrl
},
{
$Type : 'UI.DataField',
Value : createdAt,
},
/*{
$Type : 'UI.DataFieldForAction',
Action : 'PubblicationService.EntityContainer/Attachments_downloadFileFromFN',
Label : 'Scarica',
Inline : true,
}*/
],
}) {
mimeType @UI.Hidden;
value @UI.Hidden;
name @title : '{i18n>attachmentName}';
}


I add the js extension controller in ext\controller path

The users that will use the app won't have write grant but only read one. So the page is in read only mode.

This is the page whit the button table toolbar added in cds annotations, but it's not what I need.

I need the custom action button in the table toolbar but added from Manifest.json

What am I doing wrong? Is there anyone can help me?

Thank you.

Kind regards.

Claudio

Accepted Solutions (0)

Answers (0)