204
Views
7
Comments
Solved
How to disable button on the basis of roles
Application Type
Reactive
Service Studio Version
11.53.43 (Build 62091)

Hi Folks

I have a scenario wherein I actually want to disable a button on the basis of roles. But my problem is that I don't have access to the USERS session for creating new users and adding them specific role. Is there any possible way to implement them using entities and actions?


Thanks in advance

2023-02-19 05-11-08
Faais
Solution

Hi Athulya Panicker,


* Add data action in the screen that you need to hide the widget

* After that Data action provide you with one output parameter. Inside Data action you drag the checkRole server action under the logic tab -> Roles and assigned that into the output parameter 


Here is the data action flow :


* Then Go to the button. Click the visible property and assign the data action's output parameter


I have attached OML for your reference.

CheckRole.oml
2022-08-23 08-18-03
Athulya Panicker

Thank you so much @Faais  the solution totally worked. It was how I needed.

2025-03-29 20-37-49
Pedro de Sousa

Hello!
I know this is an old thread but I have to ask, according to screen lifecycle, is it safe to use data actions to hide widgets, for example using an if so it doesn't even render?

https://success.outsystems.com/documentation/11/developing_an_application/implement_application_logic/screen_and_block_lifecycle_events/

I used some encapsulated logic with a serveraction checking the role and feeding a client action a boolean value that would be called on the screen's OnInitialize, but ofcourse I got a performance warning for this.

When it comes to screenlifecycle I prefer mine since it seems safer, since the role is there before the screen is rendered. Data Action how ever, screen is rendered first then the Role checked?

Won't we risk loading what we wish to keep hidden if the Data Action loads after screen renders?

Thank you for your time,

Pedro

2023-10-21 19-42-11
Tousif Khan
Champion

Hello,

There are many ways you can do that,
You can create a screen with list of all user, and by clicking on the User you can redirect that user to a Screen where you have current selected user detail, from that page you can create a logic to assign the role to a user via a button click,

We have lot of post which explains how we can assign the role to a user programmatically,

You can also refer to this Forge
https://www.outsystems.com/forge/component-overview/13511/user-management-reactive

I hope this helps

Best Regards
Tousif Khan

2024-11-25 22-05-29
Sergio Aznar Guallar

Hi Athula,

Sure, you can do it. When creating a new app it comes with login and register screen, there you can create new users. Then. in the  logic tab you can create new roles. And finally, to assign roles to users, you can create a new screen that list your users using the system > users entity, and with some logic trigger a server action that uses a GrantXRole action

hope it helps


Kind regards,

Sergio

2024-11-25 22-05-29
Sergio Aznar Guallar

And to disable a button by depending onroles, just use CheckXRole action :)

2023-02-13 15-34-45
BabyBear

You can create an action that grants a role to a user and create a testpage with a button that calls the action you created.

2023-02-19 05-11-08
Faais
Solution

Hi Athulya Panicker,


* Add data action in the screen that you need to hide the widget

* After that Data action provide you with one output parameter. Inside Data action you drag the checkRole server action under the logic tab -> Roles and assigned that into the output parameter 


Here is the data action flow :


* Then Go to the button. Click the visible property and assign the data action's output parameter


I have attached OML for your reference.

CheckRole.oml
2022-08-23 08-18-03
Athulya Panicker

Thank you so much @Faais  the solution totally worked. It was how I needed.

2025-03-29 20-37-49
Pedro de Sousa

Hello!
I know this is an old thread but I have to ask, according to screen lifecycle, is it safe to use data actions to hide widgets, for example using an if so it doesn't even render?

https://success.outsystems.com/documentation/11/developing_an_application/implement_application_logic/screen_and_block_lifecycle_events/

I used some encapsulated logic with a serveraction checking the role and feeding a client action a boolean value that would be called on the screen's OnInitialize, but ofcourse I got a performance warning for this.

When it comes to screenlifecycle I prefer mine since it seems safer, since the role is there before the screen is rendered. Data Action how ever, screen is rendered first then the Role checked?

Won't we risk loading what we wish to keep hidden if the Data Action loads after screen renders?

Thank you for your time,

Pedro

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