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
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.
Thank you so much @Faais the solution totally worked. It was how I needed.
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
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 Forgehttps://www.outsystems.com/forge/component-overview/13511/user-management-reactive
I hope this helps
Best RegardsTousif Khan
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
And to disable a button by depending onroles, just use CheckXRole action :)
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.