How to Show a Column only to certain Users
Application Type
Reactive
Service Studio Version
11.14.16 (Build 60354)

Hello everyone,

Here goes my first question :)


I am currently participating in the development of a project (part of a learning program) where we have our components separated, which means, our roles + logic to check roles (server and client side) are both inside the Core Services.


Right now, I would like to add some logic to the Table Header and Table Row in order to show it ONLY to the Admin Role, and then the next two Column Headers and respective Rows to Human Resources.


Accordingly to this solution ( https://www.outsystems.com/forums/discussion/62886/reactive-web-application-check-role/ ) it would be easy if I had these roles created in the Interface Module, but that isn't the situation.


I would like to know how can I apply such kind solution, taking into consideration I have the Role Checks being performed in the Core Services.


Thank you very much in advance for your time and consideration.


Best regards,

Hugo Rodrigues

Hide Column and Rows.JPG

mvp_badge
MVP

Hello there Legacy,

Hope you're doing well.


You can still do that solution, you just need to define your roles in the Core Services as Public and use them as a reference in your Interface Module :)


Hope that this helps you!


Kind regards,

Rui Barradas

Hello Rui,

Thank you for the prompt reply!


Regarding what you just told me - by making that Role public, doesn't that violate the encapsulation principles?


Thank you for your time and attention :)

mvp_badge
MVP

Hello there again,

No, it doesn't :)

You have your roles define on the Core Services layer, you can use them as a dependency on your End-User layer.

It is okay to have the End-User layer consuming the Core Services layer, but not the opposite.

You can refer to this documentation about the architecture violations that you should avoid.


Anyway, it's actually a common use to define roles as public and reuse them in your End-User layer, since you can define which roles are mandatory to access a screen. As an example:


Hope that this helps you!


Kind regards,

Rui Barradas

hii..
Leg4cy

You can Create Role in other module as u said  then take the dependency on current , then select and use that , and you can do one more thing you can check by conditon also (checkrole)

i hope you will get it as you want after it you couldnt then please ping ...

I have given a more explained answer you also please refer to it

For checking weather a widget or a part of it is shown to prices role you first need to create a data action to fetch the data from that perticular role whome you want to show the widget then assign the output perimeter of the data action to the check role function of the role which you have called in data action (note that the output perimeter should have the data type of Boolean)

The second step would be to place that widget (in your case the row) into an IF and then give it the condition of the output of data action being on true 

Hello everyone,


Sorry for the late update.


Basically, for some reason, the environment I'm working at (which is used for the entire university), is not allowing me to consume the Role Actions directly in the Interface module (albeit it is set as public in the Core module).


So, the solution was the following:

1) Set a Server Action / Client Action (with JavaScript in this case), that has Boolean Outputs for each of the roles I am checking, and named it as "CheckRoles", so I can do: "CheckRoles.HasAdmin" while will be either true or false.

2) Set "CheckRoles" has public.

3) Inside the Interface Module, consume the "CheckRoles" action, and then on each screen I need to check said roles, I will have to create each variable for each role I need (Local Variables), which are Booleans (ex.: IsAdmin IsHR IsCollaborator).

4) Then I create a Client Action (Event: OnInitialize) for each screen I will be checking roles, which will use the "CheckRoles" from the Core module between the Start and End (in my case, I just need that on each screen initilization for now).

5) Then depending if the Local Variable (ex.: IsAdmin = CheckRoles.HasAdmin) changed to True, it will reveal the information (or not) necessary for each user.


This was the only workaround I was able to find for my current scenario. Hopefully this can help others in the future if they face the same issue.


I would like to thanks everyone that spared some of their time to tell me other solutions, unfortunatelly these didn't work for my scenario where many things are restricted to us (even the (Server) actions, such as "ListAppend" or "ListClear" are not usable!).


Thank you everyone, and have a nice day!


If anyone ever needs help about a more detailed guide on how to do this, let me know, albeit those 5 points should be enough to give the idea of how to do it.

mvp_badge
MVP

Hello there Legacy,

I'm not sure if I agree with your solution :)

So you're saying you're calling the CheckRoles Server Actions inside OnInitialize events? That's not the best option in therms of performance.

Can you share your OML so I can take a look?


Kind regards,

Rui Barradas

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