Skip to Content
0
Feb 01, 2023 at 04:40 AM

Is it possible to remove the mandatory parameter for a CDS entity under a FT ?

185 Views

I am referring to URL:

capire - Working with CDS Models (cloud.sap)

Dear Team,

I have an existing CDS service with the below definition. We can see that Publisher is a mandatory attribute as defined in 'BookService.BookServiceWD'.

As part of some new developments under a feature toggle, I want to remove the mandatory attribute from the Publisher field.

This attribute should be mandatory without the feature toggle and with the feature toggle it should be non-mandatory.

How could we go about implementing something like this ? If there is any sample reference, could you please share. Thanks.

using com.sap.test.datamodel as books_dm from '../db/data-model';

@cds.query.limit: { default: 50, max: 50 }

service BookService {

@readonly

entity Books as projection on books_dm.Books;

@odata.draft.enabled

entity BookServiceWD as projection on books_dm.Books;

@readonly

entity Publisher as projection on books_dm.Publisher;

};

annotate BookService.BookServiceWD with {

@mandatory

Publisher @(Common : {ValueList : {

SearchSupported : false,

Label : '{i18n>SelPublisher}',

CollectionPath : 'Publisher',

Parameters : [

{

$Type : 'Common.ValueListParameterInOut',

LocalDataProperty : Publisher,

ValueListProperty : 'Publisher' },

{

$Type : 'Common.ValueListParameterDisplayOnly',

ValueListProperty : 'PublisherName'

}

]

}});

};