116
Views
6
Comments
Solved
Read only Role

Hello,

I would like to have a role that can only read all the different screens and have no permission to write/edit anything. I have read that read-only role does not exist in Outsystems and the way to go about it is to use the CheckRole function. However, I have over 20+ screens with many inputs, any suggestions on how to achieve what I want? Or do i have to manually go over every single screen and CheckRole? Thank you!

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

Hi Low,

Indeed there is no concept of a readonly role in OutSystems. You define as a developer the role and what permissions the role has. You have two options to solve this.

  1. Use one screen for roles that allow to change data and the role to only read. Using the CheckRole function you need to condition your screens to block input and change actions to your data. This has a few advantages and disadvantages;
    • Advantage is you have one screen to maintain for both roles
    • Disadvantage are that it makes the screen widget tree and logic more comple and is easy to forget to handle each role correctly with future changes to the screen
  2. Create a seperate set of screens which only displays data. This is more work, but it has 2 important advantages:
    • It is more secure and easier to code and maintain. When you change and edit screen you cannot forget the read-only role.
    • You can define a different screen layout that better fit the users of the read-only role.

Regards,

Daniel

UserImage.jpg
Low Nico

Hi Daniel,

Thank you for your explanation! It is unfortunate that there is no readonly role for outsystems. Both options that you mention to solve this issue will take a fair bit amount of time but I guess that is the only way for now. Thank you!

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

Hi Low, yes I fully agree. It would be a nice feature if Service Studio would provide a way to make inputs automatically readonly and links and buttons disabled/hidden based on a role. 

You can submit an idea for this on www.outsystems.com/ideas

2023-10-28 11-02-41
Ruchi Dubey

Hi,

Create a reusable server action that encapsulates the logic for checking the user's role with using the (CheckRole) function.

And call it in input, screens.

Hope this help's you 

Thanks

Ruchi

2020-11-05 04-47-48
Nghia Hoang

Hi Nico, 

I believe that you have to check that for each screen/ input. And you can use the solution provided by @Ruchi Dubey  to define a reuseable function for checking that role, and remember to call that CheckRole function for any submit action before saving data to DB.


PS: One more way is to check the Role at the client site using this built-in JS function mentioned here for better performance: https://www.outsystems.com/forums/discussion/55602/how-to-check-role/ , AND REMEMBER to check role again before actually save data to DB. 

2024-05-08 06-29-37
Prince Aadil Khan Panwar

Hi Low Nico,

Try to follow these steps-

- create a static entity, and add all roles in it and keep the same names as the roles are having.

- now take the dependencies from the system for Entity- Role, UserRole, Role
- now create a server action and add Aggregate and apply these filters


and then you can put the output is true or not 

now create an data action for each screen and use that server action.
and you can use this data action on ready or on after fetch and if the action returns false the you send on another screen.

Thanks and regards

Prince

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

Hi Low,

Indeed there is no concept of a readonly role in OutSystems. You define as a developer the role and what permissions the role has. You have two options to solve this.

  1. Use one screen for roles that allow to change data and the role to only read. Using the CheckRole function you need to condition your screens to block input and change actions to your data. This has a few advantages and disadvantages;
    • Advantage is you have one screen to maintain for both roles
    • Disadvantage are that it makes the screen widget tree and logic more comple and is easy to forget to handle each role correctly with future changes to the screen
  2. Create a seperate set of screens which only displays data. This is more work, but it has 2 important advantages:
    • It is more secure and easier to code and maintain. When you change and edit screen you cannot forget the read-only role.
    • You can define a different screen layout that better fit the users of the read-only role.

Regards,

Daniel

UserImage.jpg
Low Nico

Hi Daniel,

Thank you for your explanation! It is unfortunate that there is no readonly role for outsystems. Both options that you mention to solve this issue will take a fair bit amount of time but I guess that is the only way for now. Thank you!

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

Hi Low, yes I fully agree. It would be a nice feature if Service Studio would provide a way to make inputs automatically readonly and links and buttons disabled/hidden based on a role. 

You can submit an idea for this on www.outsystems.com/ideas

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.