cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori Elements Value Help for Enums via annotation

former_member66
Advisor
Advisor

We have a CAP Java project and are building a Fiori Elements UI via CDS annotations.

We would like to provide a Value Help for one of the filter options on our List Report page.

The entity looks like this:

type ChangeEventType : String enum {
 Created;
 Updated;
 Deleted;
};

entity ChangeLogs : cuid {
  occuredAt : Timestamp;
  eventType : ChangeEventType;
...
}

From my understanding of the documentation (https://github.wdf.sap.corp/pages/cap/advanced/fiori#value-help-support) value help is only supported for Entities or CodeLists.

How would I add a value help via cds annotations for a type Enum property?

leoirudayam
Advisor
Advisor
0 Kudos

Any updates on this?

0 Kudos

I had the exact same question. Any answer or suggestion would be helpful.

@lenahammerer Did you get any solution for this?

petr_stribrny
Explorer
0 Kudos

Hi,

I've notified the annotation modeler colleagues, they will update you soon.

Best Regards,

Petr

rex_yin
Employee
Employee
0 Kudos

hello, any update for this? @petr.stribrny

petr_stribrny
Explorer
0 Kudos

Hello Rex Yin,

I'm sorry you haven't received an answer yet. Let me check, me or colleagues will reply soon. Thanks.

Best Regards,

Petr

Accepted Solutions (1)

Accepted Solutions (1)

c-kobo
Advisor
Advisor
0 Kudos

Hi Lena,

For providing a value help in Fiori elements, you always require a ValueList annotation on the corresponding entity property. The ValueList annotation contains property 'CollectionPath' pointing to the values providing entity. So, from a service $metadata perspective, there is no codelist, but entities with properties.
In CAP, defining an entity based on aspect CodeList only generates the ValueList annotation for you at CDS compilation, and it also contains the collection path pointing to the codelist based entity that is exposed with the service.

This gets more clear if you look at the existing ValueList Annotations of your service's metadata.
Explanation with example can be found here:
https://github.com/SAP-samples/fiori-elements-feature-showcase/blob/main/README.md#value-help

For your use case, I would recommend to put an enum typed property inside an aspect of type CodeList (and put a Text with TextArrangment annotation in there so that the name is shown instead of the code), and then use it in an VH entity and for your ChangeLogs entity.

Like this you get the ValueList Annotation for free.

You can btw. override the default ValueList Annotation by simply defining it again explicitely.

Without having tested it, your code would look somthing like this:

aspect ChangeEvents : CodeList { @( Common : { Text : name, TextArrangement : #TextOnly } ) key code : String enum { Created = 'C'; Updated = 'U'; Deleted = 'D'; }};
entity ChangeEvent: ChangeEvents {};
entity ChangeLogs : cuid, ChangeEvents { occuredAt: Timestamp;}
annotate ChangeLogs with { code @(Common : { Text : name, TextArrangement : #TextOnly, ValueList : { Label : '{i18n>ChangeEvent}', CollectionPath : 'ChangeEvent', Parameters : [ { $Type : 'Common.ValueListParameterInOut', ValueListProperty : 'code', LocalDataProperty : code }, { $Type: 'Common.ValueListParameterDisplayOnly', ValueListProperty: 'name', } ] } });};

Hope that helps.

Best regards

Christian

Answers (0)