15
Views
4
Comments
Solved
How to show/hide icon regarding Role - OS Reactive
Question

Hi all,

I´m using OS11 and the new to the reactive framework.

I've made a simple app where there´s a users page that contains a user table and i want to check if a user of the table has or not a role.

I have already tried with the Web method, due to the fact that i´m used to work with it but found out that the logic doesn´t work in the same way, I already saw  and try the javaScript:

$parameters.IsManager = $public.Security.checkIfCurrentUserHasRole($roles.MyAppManager); 

but it´s not what i need.
I am venturing on the reactive side so if anybody can help I appreciate it

Thank you!

Rank: #70
Solution

Hi Diogo,


Now I understand your question.

Since you are fetching the user data from a server side query to bind to the list, you can also fetch if the user has the MuAppManagerRole on that list.

You would just have to (left) join with User_Effective_Role table that has the roles that each user has.

Then you can use that field on the if (on my example HasAppManagerRole field):



Just be careful and make it a left join (With or Without) to still get the users that don't have the role.

Hope it helps.


Cheers,

João 

Rank: #70

Hi Diogo,


What do you mean by reactive side?


There the built-in server side function with Check<Role>Role(UserId) - CheckMuAppManagerRole() - in your case -  and the client side way using Javascript as you mentioned to be called on the OnReady.


Those are the only two ways.


Cheers,

João

Rank: #70
Solution

Hi Diogo,


Now I understand your question.

Since you are fetching the user data from a server side query to bind to the list, you can also fetch if the user has the MuAppManagerRole on that list.

You would just have to (left) join with User_Effective_Role table that has the roles that each user has.

Then you can use that field on the if (on my example HasAppManagerRole field):



Just be careful and make it a left join (With or Without) to still get the users that don't have the role.

Hope it helps.


Cheers,

João 

Rank: #6054

Thanks Joao is now working :D