Restricting User Access to Unassigned Tickets in Frappe Helpdesk

Hi team,

While using Frappe Helpdesk, I’ve created tickets and assigned them to a user. However, I am unable to restrict the user from accessing unassigned tickets. I have tried using user permissions , it doesn’t seem to work. Could there be something I’m missing? Please help me resolving this matter.

Any Update on This ???

I have implemented some quick hacks to enable this feature.

1 . I have created a new “HD Preset Filter” by setting the condition to the field ‘_assign’ as ‘@me’.

2 . Then, I created a user permission document for the user who needs to be restricted from unassigned tickets.

3 . I have overridden the function ‘get_preset_filters’ (path: helpdesk/helpdesk/api/general.py at main · frappe/helpdesk · GitHub) by adding a new condition: if user permission exists for the user.

Please refer the below code:


@frappe.whitelist()
def get_preset_filters(doctype):
	"""
	Args:
	                doctype (_type_): _description_

	Returns:
	                Dict {"user": [], "global": []}: Returns the preset filters for a given doctype
	"""

	options = {"user": [], "global": []}
	data = []
	user_permissions = frappe.get_all(
        "User Permission",
        filters={"allow":"HD Preset Filter" , "user": frappe.session.user},
        fields=["name", "for_value"],
    )
	if user_permissions:
		for doc_name in user_permissions:
			data.append((doc_name.for_value ,))
		preset_filters = list(data)
	else:
		fd_preset_filter = frappe.qb.DocType("HD Preset Filter")
		preset_filters = list(
			(
				frappe.qb.from_(fd_preset_filter)
				.select(fd_preset_filter.name)
				.where(
					(
						(
							(fd_preset_filter.type == "User")
							& (fd_preset_filter.user == frappe.session.user)
						)
						| (fd_preset_filter.type.isin(["Global", "System"]))
					)
					& (fd_preset_filter.reference_doctype == doctype)
				)
				.orderby(fd_preset_filter.type)
				.orderby(fd_preset_filter.modified, order=Order.desc)
			).run()
		)

	for preset_filter in preset_filters:
		preset_filter_doc = frappe.get_doc("HD Preset Filter", preset_filter[0])
		options[
			"global" if preset_filter_doc.type in ["Global", "System"] else "user"
		].append(preset_filter_doc)
	return options

4 . After implementing this code, the user will only see assigned tickets in the helpdesk view.