How to hide menu and buttons based on role?
Hi,
You can check this post and use the same approach. Please, see all the responses, maybe the JS approach (by João Marques) is a nice one: https://www.outsystems.com/forums/discussion/67036/how-to-hide-buttons-based-on-role/
Hope this can help.
Best regards,
Ricardo Pereira
Hi Aneena,
You can use an If widget to achieve this.
In the condition of your If you should evaluate if the user has the specific role you want to check, and then place your button, menu item, etc... in the True branch.
For more information please check these links:
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Interfaces/Designing_Screens/If_Widget (regarding the if widget)
https://success.outsystems.com/Documentation/11/Developing_an_Application/Secure_the_Application/User_Roles/Validate_End_User_Permissions_in_the_Application (regarding the roles)
Hello Aneena,
Please check below post and there is one oml file also. You can refer it.
https://www.outsystems.com/forums/discussion/62878/how-to-define-seen-or-unseen-button-with-roles-in-reactive-app/
Regards,
Ajit Kurane.
Hello, so as we can see, there is a lot of information, just choose or look at all the information. Any doubts we are here to help you if you need.
I will leave here some more links
https://www.outsystems.com/forums/discussion/67842/how-to-set-a-button-from-menu-invisible-depending-on-user-role/
https://www.outsystems.com/forums/discussion/40330/how-to-disable-or-enable-button-based-on-user-roles/
https://www.outsystems.com/forums/discussion/55602/how-to-check-role/
Next time someone asks this same question, this will be the link that I am going to give and only this :D
Wish you the best!
Márcio
You can try what Ricardo and Pedro suggested.
Else, You can make this possible if you insert the button or menu item in a container and in the containers visible property add the check role logic, like,
if (IsManager or IsAdmin, True, False)
This IsManager or IsAdmin are the Boolean values for the Rolecheck purpose.
Hi Aditya,
Just one point: You don't need to validate with an If with the true and false branches. You just need to use the true condition to validate (in this case, you just need to use the IsManager or IsAdmin).
And it's better to use an If widget instead of the visible property of the container, because with the If its guaranteed that the container don't appear in the HTML.
Ricardo
Hi Ricardo,
Yeah You are right. I thought that the requirement is just for one or two items, so that's why I suggested it. Thanks for the information.
Thank you all, I got the answer to my question.