on 11-11-2022 1:59 PM
Dear SAP-Community,
I'm trying to model a bookshop with the entities Books and Authors:
entity Books {
key guid : UUID;
title : String(20);
stock : Integer;
year : String(4);
author : Association to Authors;
edition : String;
}
entity Authors {
key guid : UUID;
firstName : String(30);
lastName : String(20);
born : Integer;
books : Association to many Books
on books.author = $self;
}
I want to display the full name of the author in one or two columns in an Fiori Elements App.
For the app I have the following service:
using my.bookshop as my from '../db/data-model';
@path: 'service/books'
service CatalogService {
entity Books as projection on my.Books
{
key guid,
title,
stock,
year,
author,
edition
};
entity Authors as projection on my.Authors;
}
And the following annotations:
using CatalogService as CatService from '../srv/cat-service';
annotate CatService.Books with @(
UI: {
HeaderInfo : {
TypeName : '{i18n>Books.TypeName}',
TypeNamePlural : '{i18n>Books.TypeNamePlural}',
Title : { $Type: 'UI.DataField', Value: title },
},
SelectionFields : [ title, stock, year ],
LineItem : [
{$Type: 'UI.DataField', Value: guid, @UI.Hidden},
{$Type: 'UI.DataField', Value: author_guid},
{$Type: 'UI.DataField', Value: title},
{$Type: 'UI.DataField', Value: year},
{$Type: 'UI.DataField', Value: edition},
{$Type: 'UI.DataField', Value: stock}
],
},
);
annotate CatService.Books with {
author @(Common : {
Text: author.lastName,
TextArrangement : #TextOnly,
ValueList : {
Label: 'Autor',
$Type : 'Common.ValueListType',
CollectionPath : 'Authors',
Parameters: [
{
$Type: 'Common.ValueListParameterInOut',
LocalDataProperty: author_guid,
ValueListProperty: 'guid'
},
{
$Type: 'Common.ValueListParameterDisplayOnly',
ValueListProperty: 'lastName'
}
]
},
})
};
// Properties Object Page
annotate CatService.Books with @(UI : {
Facets : [{
$Type : 'UI.ReferenceFacet',
Label : title,
Target : '@UI.FieldGroup#Main',
}],
FieldGroup #Main : {Data : [
{Value : author_guid},
{Value : title},
{Value : stock},
{Value : edition},
{Value : year}
]},
});
annotate CatService.Books with {
//ID @( Common: { Label: '{i18n>Books.ID}'});
title @( Common: { Label: '{i18n>Books.title}'});
stock @( Common: { Label: '{i18n>Books.stock}'});
year @( Common: { Label: '{i18n>Books.year}'});
author @( Common: { Label: '{i18n>Books.author}'});
edition @( Common: { Label: '{i18n>Books.edition}'});
};
I don't know how to add the firstName to the author annotation.
Thanks for your help!
- Anton
I would suggest you have a look at the sample app: fiori/app/common.cds
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.