User Roles Assigned to users

We have more then 1000 user and more then 20 roles. My boss assigned me task that export/make list of users which are member of “juniors”(A role name in our scenario) role. I tried so much but I didn’t found any option like this. What I think I can do is check each user role by checking each user profile. which is not a feasible solution at all. Please help in the regard.

Hey @jaz,
Have you tried using the API? Users - DHIS2 API Documentation

Here’s a simple and short suggestion from a beginner like me. For example, from this API request (/2.36.3/api/userRoles) I got the ID of the role that I want (you’d use the ID for “juniors” in your case) and then sending the request with that ID (/2.36.3/api/userRoles/UYXOT4A7JMI) lists IDs for users with this role. If you want all the user information, you’d do the same to get the list of users easily done from the Import/Export app and then compare IDs in both lists.

If you must do this all the time then either a script, feature request, or an advice given to you from the DHIS2 experts, would help you a lot more! Please let me know if my suggestion works for you, thank you!

Thanks @Gassim. It helps me but still I need to match each ID to get exact thing. And through API I get 500 results. Which is still a tough job. Is there is no other way form where I can export/view users list with their roles.

Hi Jahanzeb,

Try:

YOURBASEURL/api/userRoles?&fields=name,users[displayName,userCredentials[username]]&paging=false

The data shown is XML but you should be able to find what you need.

Paul

1 Like

@prcleary :smiley: Thank you so much for sharing! I was so close and I’m honored by your answer completing my unfinished task! :pray::blush:

Hope it helps @jaz. Please mark as solution if it’s resolved! Thank you! ( :