How to list all users with certain roles
Application Type
Traditional Web

Hello everyone!


I'm having a problem listing a user list with roles

I have 5 roles in my app

I need to list all users who have these roles, but a user can have two or three roles,

My problem is when a user has two or more roles, my query lists two or more lines from the same user (for each role)

I need the user to be listed only once, if he has one or 5 roles


How can I solve this problem?




Hello everybody.


I want to thank you for all the replies, I managed to fix my problem, and the set of information helped me to reach the following result


I created a new calculation attribute in the aggregate and made

If (Role.Id = Internal(... 1) or Role.Id = Internal(... 2) or Role.Id = Internal(... 3), "Internal", Role.Name)


I made a group for this attribute and it worked.


Regards

Dairon

Hi Dairon,

To only have one row per user, you just group on the user id attribute, and any other you would like to show, such as user name.

One thing to also consider : you should maybe look at user_effective_role instead of user_role, as the OS user module supports granting rules to groups of users, and that won´ t show up in you query. 

Dorine

Hi Dorine, thanks for repply.


I got it and I tryed do it, and work, but, whit a problem.


I have 3 of 5 roles, that are internal user (...)

In my grid, I have a column that I need to verify if that user has one of them role, that is, I need to return the roles too

If I group by RoleId, I have 3 register again.

Ok,

So if I understand correctly, if a user has one of these specific roles, it should be flagged in your UI as a special user (what you call 'internal user'), but there should only be one row per user.

You could add a calculated column to your aggregate, see attached oml.  Is that what you mean?  In my example I want to show all users with a role named administrator as special users, but that would be your logic on what exact user you consider 'internal'.

Dorine

QDRUserRoleAggregate.oml

Hello Dairon, 

You can always split the listings between a screen and a webblock, where on the screen you have the aggregate that feeds a list of employees and then you have a webblock with the roles of a user, which you will use within the employee list. I enclose the stream of images that I used to solve the problem. I hope it helps.




Regards,

Jorge Rodrigues

Hello everybody.


I want to thank you for all the replies, I managed to fix my problem, and the set of information helped me to reach the following result


I created a new calculation attribute in the aggregate and made

If (Role.Id = Internal(... 1) or Role.Id = Internal(... 2) or Role.Id = Internal(... 3), "Internal", Role.Name)


I made a group for this attribute and it worked.


Regards

Dairon

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