10
Views
9
Comments
Solved
Created Roles don't appear on button enabled
Application Type
Reactive
Service Studio Version
11.10.10 (Build 38781)

I created my Roles in a core module as you can see at the image below.

Then I published the module and go to the other module to managed the dependencies.

After that I needed to permit a click at a button base on a Role. So i went to the button, click on enabled property and when I was searching for the CheckEmployeeRole it's not appear on the list, as you can see at the image below.


So, what I am doing wrong? How can I permit a button click based in a Role?


Thanks for you help.

Rank: #86
Solution

Hello there Pedro,

Hope you're doing well.


Please refer to this thread, it seems that you're facing a similar issue:

https://www.outsystems.com/forums/discussion/68385/if-statement-to-hide-links-based-on-role/

(Check this post)


Hope that this helps you!


Kind regards,

Rui Barradas

Rank: #7979

So, if I want to hide some menu items or a button after login, I can not you Ckeck<RoleName>Role?

I need do a client action to check the Role on initialize event for example? It's like preparations in Traditional Web?

Rank: #56

Hi Pedro,


You cannot use the Check<RoleName>Role, because it's a server-side function and on the if, you can only use Client-side functions.

The OnInitialize runs before the screen is loaded (kind of but not really like Preparation, you can read more here) and via Javascript you can get the roles avoiding calls to server side and thus it is better for performance.


Kind Regards,
João

Rank: #86

Hello there Pedro,

For RWAs, you can use the Check<RoleName>Role action in an Server action or Client action. But you cannot use it directly in a screen (meaning using it for expressions). In these RWAs, 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.


As mentioned in the post that I've shared with you, you could either call this Check<RoleName>Role action in a client action (event of the screen/block) or do this using JavaScript.

JavaScript is indeed more performant (since it avoids server calls), but Client Side Roles can easily be tampered using browser tools. That's why you should not rely on them if you're working for example with sensitive information or storing data in the database.


Another suggestion would be the usage of Client Side roles (JavaScript) to show/hide the button, but then you can validate this role again in the Server action using Check<RoleName>Role action (just to make sure that the application is secure).


Kind regards,

Rui Barradas

Rank: #56

Hi Pedro,


You need to have the roles property Public set to True, so they can be consumed and appear on the manage dependencies screen.


Kind regards,

João

Rank: #7979

I didn't put a image but had set the Public property as TRUE

Rank: #301

Hi Pedro,

Please see below screen shot to make the roles accessible into another module for your ready reference.

Thanks & Kind Regards,

Sachin

Rank: #7979

I didn't put a image but had set the Public property as TRUE

Rank: #301

It would not be possible to get the roles into the buttons enabled property. In the enabled property you can only mark it as True or False. If you want to apply some logic on the button based on the role you defined into the core module you have to write logic into the screen event or other actions.

Rank: #86
Solution

Hello there Pedro,

Hope you're doing well.


Please refer to this thread, it seems that you're facing a similar issue:

https://www.outsystems.com/forums/discussion/68385/if-statement-to-hide-links-based-on-role/

(Check this post)


Hope that this helps you!


Kind regards,

Rui Barradas

Rank: #7979

So, if I want to hide some menu items or a button after login, I can not you Ckeck<RoleName>Role?

I need do a client action to check the Role on initialize event for example? It's like preparations in Traditional Web?

Rank: #56

Hi Pedro,


You cannot use the Check<RoleName>Role, because it's a server-side function and on the if, you can only use Client-side functions.

The OnInitialize runs before the screen is loaded (kind of but not really like Preparation, you can read more here) and via Javascript you can get the roles avoiding calls to server side and thus it is better for performance.


Kind Regards,
João

Rank: #86

Hello there Pedro,

For RWAs, you can use the Check<RoleName>Role action in an Server action or Client action. But you cannot use it directly in a screen (meaning using it for expressions). In these RWAs, 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.


As mentioned in the post that I've shared with you, you could either call this Check<RoleName>Role action in a client action (event of the screen/block) or do this using JavaScript.

JavaScript is indeed more performant (since it avoids server calls), but Client Side Roles can easily be tampered using browser tools. That's why you should not rely on them if you're working for example with sensitive information or storing data in the database.


Another suggestion would be the usage of Client Side roles (JavaScript) to show/hide the button, but then you can validate this role again in the Server action using Check<RoleName>Role action (just to make sure that the application is secure).


Kind regards,

Rui Barradas