Federico Belotti
Federico Belotti

Reputation: 11

How can I programmatically hide/disable the Edit button in a CAP-based Fiori Elements (OData V4) application through annotations?

I have a CAP application that exposes different service and built a Fiori Elements (OData V4, ListReport + ObjectPage) application and customized it with annotations on the backend side since I want to use CDS annotations. I'm trying to hide (or disable) or let visible the standard Edit button in the ObjectPage header through the evaluation of a custom property (isEditable, boolean) of the entity managed by the application, so that for certain instances the edit operation is not possible.

According to the documentation this seems to be possible, but nothing I tried is working. I tried annotating the entity itself with the annotation @UI.UpdateHidden: isEditable but I can still see the button. The annotation works fine if I set it's value to false, but it's not what I'm looking for. This is the annotation used on the service entity:

annotate service.Foo with @(
    UI.UpdateHidden: isEditable
);

It's also worth noting that this is a draft-enabled Fiori application, so the Edit button is visible by default, I didn't do anything to explicitly enable it.

Is there something I can do with annotations? Is there another way to accomplish this?

Upvotes: 1

Views: 47

Answers (1)

Pratyush
Pratyush

Reputation: 13

UI.UpdateHidden: {$edmJson: {$Eq: [{$Path: 'someProperty'}, true]}},

Whenever the value of someProperty is true the Edit button will be hidden on the UI

Hope this helps!

Upvotes: 0

Related Questions