Retrieve assigned users list of a Role

Hello everyone,


I have a requirement to retrieve list of users of a specific role. I searched the forum and found that we could user below 3 tables from system to do so:



I added below conditions:



When i tried to compare Id field (either of Role table or User_effective_Role) directly to application "Admin" roles (Roles.Admin), The results is not matching actual user list (it is list of another role from another application).


When i changed the logic to role name and also added Espace_ID check, then it returns actual user list. But here is one concern that it also included Administrator users which i want to exclude, so how could i do it?  

Second concern is that, i removed role assignment for one of admin user using Users module UI but above query was still returning all users including the removed one.


Can any one clarify these concerns?

Hi Bilal,

Does the requirement is to get the list from within an app or a plain list which can also be retrieved from LifeTime?

Regards,

Swatantra

For a list of users per role, you may navigate each role and will get the list of users assigned a particular role e.g. Developer role:  https://lifetimeoutsystemsserver/lifetime/Role_Edit.aspx?RoleId=2 

Swatantra - I am working on a flow kind application. Where on a specific stage, i need to show list of current stage role's user so that a supervisor can assign each request to one of the desired users.


Mean a dropdown of current stage roles user will be displayed on screen.


As in my initial question, i am able to get list but there are some issues, which i have explained, i want to get solution of them.

Hi Bilal Iqbal,

Correct me if I am wrong, As per the screen shot , it seems that you are having a custom role table[Role_System] which is mapped to user [Users] and the mapping relation is stored in [User_Effective_Role].

Here you want to get this list of user for a particular role[Current role].So the question arises what is the current role and where is it coming from .Suppose if the logged in user is having multiple role the you need to get all the role that the use has and you create a common function where you will pass role and get the list of users[Your current logic]. You have to get the user list for all the role and append it to one list .

[I would suggest to user Advance SQL for this . You need to create a string of concatenated role list and use in logic to get the user]

OR

If are having a drop down or something like that which shows all the role that the user has and you what to get other users that belong to same role then you can use the same logic ,the only thing is that yo need to pass the role as a parameter to aggregate and the logic should be called base the change of role selection.

I hope you got it . 



Pranav Pandey wrote:

Hi Bilal Iqbal,

Correct me if I am wrong, As per the screen shot , it seems that you are having a custom role table[Role_System] which is mapped to user [Users] and the mapping relation is stored in [User_Effective_Role].

Here you want to get this list of user for a particular role[Current role].So the question arises what is the current role and where is it coming from .Suppose if the logged in user is having multiple role the you need to get all the role that the use has and you create a common function where you will pass role and get the list of users[Your current logic]. You have to get the user list for all the role and append it to one list .

[I would suggest to user Advance SQL for this . You need to create a string of concatenated role list and use in logic to get the user]

OR

If are having a drop down or something like that which shows all the role that the user has and you what to get other users that belong to same role then you can use the same logic ,the only thing is that yo need to pass the role as a parameter to aggregate and the logic should be called base the change of role selection.

I hope you got it . 



Pranav,


Role table which is in sanp shot, it is built in table of "System" module, it is showing in this way because i have one of my own table with same name.


Second point, I want to create a method to get users of a specific role only e.g. GetRole1Users, where Role1 is name of role, so that in my snapshot i am using "Admin" role.


I am able to get the results but my concerns are:


1. If compare the Id field of "Role" table, with respective role entity record (it return wrong Id) and i am getting result for another role


2. If i change the logic to compare role name, then even if i remove one user from role, it keep showing me that user.