Skip to main content
OutSystems

How to use roles to show or hide some element

Question

How to display or hide the menu on runtime, based on the role of the user?

Answer

Use the action Check<YourRole>Role action that's available above the Role on the Roles Folder.

  • The input UserId can be the Session.UserId to validate the permissions of the user logged into your application.
  • The output Has Role can be used as the condition of an If widget.

unnamed.png

The action receives a UserId and has the output HasRole that determines whether the user

For example, you can just drag the entity CheckOrderManagerRole to the Preparation action of your Menu. Select the UserId to validate the role.

unnamed (1).png

Then, use the output of the action inside an If widget to control whether the MenuItem is going to be displayed.

unnamed (2).png