129
Views
12
Comments
Fetching users based on roles

Hello Everyone, I am trying to fetch users aggregates based on their role, checkrole method doesnt work for me when i try to filter is there other way? 

Thank you! 

2026-04-23 05-29-20
Prince Kumar

Hi @norah as

Please review this link as it may be similar to what you are seeking. 

I trust that this information will assist you in resolving your issue. 

Thanks 

Prince Kumar

2025-02-10 17-24-13
Arun Rajput

Hi norah,

You can use User, Role, UserRole to fetch user on the basis of role.


This all three entity has relationship so on the basis of user id and role name you can get users details.

-Arun

UserImage.jpg
norah as

Thank you, but these entities dont exsist mine is latest version of service studio O11 

2025-02-10 17-24-13
Arun Rajput

I am also using O11 and it's there, did you take dependency from System Module.

2019-01-07 16-04-16
Siya
 
MVP

May be you could share the screen shot of the 'Manage Dependency' so that community member could understand what exactly the issue is. ( Do choose "In Use" for modules and select "(System)" and "In use" for elements on the right ). 

Do check you have selected User, Role & User_Effective_Role as suggested by community members.

2024-06-30 04-29-36
Priya Jhode
2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi all,

I see several answers referring to User_Role.

If the requirement is to know if a user has a given role, this answer is incomplete, because users can also have roles because they are member of a group.

The only way to capture them all is to use User_Effective_Role, not User_Role.

Dorine

2023-01-17 13-43-47
Akhila K Soman

Hi @norah as ,

You can take the dependencies for User, Role, UserRole  entities from the System module as follows.


Hope this helps.

Thanks,

Akhila K Soman

2024-05-30 10-12-48
Anushka singh

Hello

If you want to filter users by a specific role ( Admin), you can add a filter like : UsersWithRole -Base Entity: User, UsersWithRole 

User_Role (Join condition: User.Id  = User_Role.UserId )

If you want to filter users by a specific role ( Admin) -User_Role.RoleId = GetRoleIdByName(Admin)

I hope it Helps!

2024-06-08 15-17-54
Nawaz Khan

@norah as already shared by @Akhila K Soman you can add the dependent tables from the (System) module but for the specific roles I believe you can target the specific role directly instead using the GetRoleByName action as shared by @Anushka singh.

Once you define the roles in the module you will have the (Roles) which will show you defined role and will get you the role identifier directly. You can also use Roles.[RoleName] anywhere in the module if you need to satisfy any condition 



UserImage.jpg
Peter Delrue

Role.Id = Roles.Admin (or any other role) does not work for me


UserImage.jpg
Francisca Fernandes

If you need to get all users that have a certain role, you can use the User_Effective_Role entity from the (System) module. This entity stores the roles assigned to a user directly or via a group. In the filter, you can select a role to filter by it, for example:

Tip: In the expression window you can just double-click the role to add it to the expression.


If you need to get all the roles a certain user has, you can use the User_Effective_Role, Role and Espace entities, like so:

I found that you have to filter by active roles and eSpaces, otherwise you'll get roles that no longer exist because they were deleted or the module they existed in was deleted.

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