cancel
Showing results for 
Search instead for 
Did you mean: 

CAP UI Controls editability

T1mey
Participant

Hello,

I'm searching for a way in SAP CAP (NodeJS) to change the editability of UI controls during runtime.

So 2 use cases.

1. based on a role (e.g. admin)

2. based on business logic (e.g. if a checkbox is marked another field gets readonly)

Think I for case one I can use @restrict annotation. Not sure how the UI behaves (readonly or invisible). Will try is asap. --> Result was that using

@restrict: [{grant:'*', to: 'admin'}]
requestor : User;

has no effect on the UI. Think this is not supported on field level.

But for case two I did not find a solution yet. Somebody an idea?

Accepted Solutions (1)

Accepted Solutions (1)

T1mey
Participant
0 Kudos

As we had problems to implement this in the "on after handler" in nodeJS we thought that maybe a local annotation of the odata service could help.

So we implemented that ... an with a location annotation it is working !

monokizsolt7
Participant
0 Kudos

Can you please share your solution?

Answers (3)

Answers (3)

T1mey
Participant

Found a solution ... See

https://sap.github.io/odata-vocabularies/vocabularies/Common.html

FieldControlType

in combination with a virtual field of type Integer.

T1mey
Participant
0 Kudos

solved it wit local annotations...

gregorw
Active Contributor

Anything that you can share / write a blog post about it?

T1mey
Participant
0 Kudos

So my suggested solution does not work if the fields, the calculation is based on, are located on another tab.

Here an example:

I want to set Name and Version input fields on first tab to readonly if a field/checkbox which is locatedon 3rd tab is set true (is checked).

So I implemented

this.after("READ", "Applications", async (data, req) => {<br>
...
}

The problem is now that in this after event only the visible fields on tab 1 are present in "data" and not the one's from 3rd tab.

Any way to have

FieldControlDynamicIf

like described here https://sapui5.hana.ondemand.com/sdk/#/topic/0e7b890677c240b8ba65f8e8d417c048

Or can I enforce to load all data in one call (for all tabs)?