If statement to hide links based on role
Question

Hello,  In older version I could hide links with the If condition.


I don't see the Check roles anymore.

how can I easily hide these links based on a "SuperUser" role I have made


Old way


NEW WAY. does not give me the "CheckSuperUserRole(UserId)


mvp_badge
MVP
Solution

Hello Dan,

Hope you're doing well.


It seems that you are working on a Reactive Web Application nowadays and you were working on a Traditional Web Application before.

In Traditional Web Applications everything is done Server Side, so you are able to call these Check<Role>Role functions directly in the screen.

In Reactive Web Applications, you have a Client vs Server concept. So you are not allowed to call these Check<Role>Role functions directly in the screen (Client Side) because they run Server Side.


What you can do in this scenario is to call this Check<Role>Role action inside an event of the screen/block, assign the result to a local variable and use that variable to control what you want to show in the screen.


Another alternative is to use JavaScript to check for the role directly in the Client Side (avoids a server call).

You just need to add a JavaScript tool in a Client Action and invoke the checkIfCurrentUserHasRole function as explained in here: https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/JavaScript_API/Security


Please be aware that Client Side Roles can easily be tampered using browser tools, so you should always validate Server Side if you are getting or storing data. Also, you shouldn't rely on this to enable access to sensitive information.


Please check these threads with some nice explanations that may help you:
https://www.outsystems.com/forums/discussion/55602/how-to-check-role/
https://www.outsystems.com/forums/discussion/29777/cannot-use-check-roles-function/
https://www.outsystems.com/forums/discussion/63633/reactive-web-and-roles/


Hope that this helps you!


Kind regards,

Rui Barradas

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