Get list of all users with a role

Hi all,

How can we get the list of all users having a specific role in the python class?

Thanks in advance for the answers…

Until frappe7

frappe.db.sql("SELECT DISTINCT parent FROM `tabUser Role` WHERE role=%s", ("System Manager",))

In frappe8

frappe.db.sql("SELECT DISTINCT parent FROM `tabHas Role` WHERE role=%s", ("System Manager",))
4 Likes

Thanks @max_morais_dmm

frappe.db.sql(“SELECT DISTINCT parent FROM tabUserRole WHERE role=%s”, (“System Manager”,))

this works :thumbsup:

We can find the frappe version with frappe.__version__ right?

@ninjas005 yes