ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

How to use get_query to get User containing a role?


#1

How to use get_query to get User containing a role?
How do I make a report to screen Users for a role?
Thanks.


#2

Please help me.


#3

For retrieving the role, see the accepted answer :

Can you elaborate your use case here ?


#4

I added a filter to report to find users with a role.
For example,

{
	"fieldname": "customer",
	"label": __("Customer"),
	"fieldtype": "Link",
	"options": "User",
	"default":"",
	"get_query": function () {
		return {
			filters: [
				["UserRole", "role", "=", "Customer"]
			]
		}
	}
},

#5

This one I wrote was unsuccessful. I don’t know how to filter Link through Role.


#6

Can someone help me? Thank you.


#7

@Wjp43045 Can you explain me briefly…?


#8

Try:
frappe.get_roles(frappe.session.user)


#9

I added a filter to report to find users with a role.
For example,

{
	"fieldname": "customer",
	"label": __("Customer"),
	"fieldtype": "Link",
	"options": "User",
	"default":"",
	"get_query": function () {
		return {
			filters: [
				["UserRole", "role", "=", "Customer"]
			]
		}
	}
},

#10

Sorry, I’m not trying to get the role of the logged-in user, but to use filter to filter all Users with a role in the report