As you may know, SAP Cloud 4 Customer offers a standard object called UISwitch to influence the standard field properties based on the user role.
How to use it?
The UI Switch is an object that can be assigned to any business Role. Any standard screen extension is able to recognize if the user has some role associated with the UI Switch and based on this information, it can change the field properties as defined by the developer.
Create the UISwitch in the PDI
In any standard screen extension, you can modify field properties (via extensibility explorer) and make these properties dependant from the UI Switch
The limitation to this fact is that there is no standard way to use UI Switch (and so business role authorization) for your custom developments.
Here a simple trick to make it working for all the kinds of developments 🙂
Create the UI Switch as shown before
Add an indicator (or some other kind of field if you need) and an action to your custom BO
Implement the action as shown below (highlighted part). Note that Context.GetCurrentUserUISwitches() is a standard method always available in the ABSL library.
In your custom screen bind the favourited property of your fields to the (in this example) indicator field
In the initialization of your screen call the action that refresh the status of the indicator field, based on the user business role
Testing the UI Switch
Create a new business role and assign the UI Switch to it
Assign the Business Role to the user