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!
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
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
Thank you, but these entities dont exsist mine is latest version of service studio O11
I am also using O11 and it's there, did you take dependency from System Module.
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.
Hello, @norah as
I am attaching this post based on users & roles. Both these solutions will helps you.
https://www.outsystems.com/forums/discussion/72959/filter-an-aggregate-based-on-user-role-reactive/#Post298313
https://www.outsystems.com/forums/discussion/54247/filter-aggregate-by-role/#Post239615
Thanks & Regards,
-- Priya Jhode
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
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
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!
@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
Role.Id = Roles.Admin (or any other role) does not work for me
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.