User Roles

Hello Everyone!
How do I find a list of users who don’t have assigned user roles?

Hi @AllanLusui

Welcome back to the community!

A user is required to be assigned a user role. It’s not possible to create one without assigning a user role:

Thanks!!
I was investigating why some macros were failing and I suspected this was the issue!
Let me keep digging!
Thanks!

As @Gassim notes: you now should not be able to create a new user without assigning a user role, but you may have users without user roles if you have an older instance or have performed operations directly on the database.

If you are comfortable looking at information via our api, you could make a call to your instance: {yourInstanceURL}/api/users?paging=false&fields=id,name,userRoles~size&filter=userRoles:le:0

This will return any users that have 0 assigned roles.

(documentation: Developer Manual - DHIS2 Documentation)

1 Like

This worked!
I had to write a few macros to get the solution eventually from our extraction tool.
But the API call was way easier!

1 Like