Skip to content
8 changes: 5 additions & 3 deletions helpdesk/helpdesk/doctype/hd_agent/hd_agent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2022, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.ui.form.on("HD Agent", {
// refresh: function(frm) {
// }
frappe.ui.form.on('HD Agent', {
refresh: function(frm) {
// Example: make status editable
frm.set_df_property('availability_status', 'read_only', 0);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed

Copy link
Author

@Shindhu-Ramaswamy Shindhu-Ramaswamy Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the unwanted code

});
21 changes: 19 additions & 2 deletions helpdesk/helpdesk/doctype/hd_agent/hd_agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"user",
"agent_name",
"user_image",
"is_active"
"is_active",
"availability_status",
"signature"
],
"fields": [
{
Expand All @@ -34,6 +36,21 @@
"in_list_view": 1,
"label": "Is Active"
},
{
"default": "Available",
"fieldname": "availability_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Availability Status",
"options": "Available\nAway",
"reqd": 1
},
{
"description": "automatically added in reply section",
"fieldname": "signature",
"fieldtype": "Small Text",
"label": "Signature"
Comment on lines 12 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that these are also shown in the "Profile" tab shown in "Settings Modal" both signature and status field

Copy link
Author

@Shindhu-Ramaswamy Shindhu-Ramaswamy Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixed in commit 910edf4 — added both fields to Profile.vue"

},
{
"fieldname": "user_image",
"fieldtype": "Attach Image",
Expand All @@ -42,7 +59,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2026-02-02 11:15:47.402850",
"modified": "2026-02-09 22:08:22.055831",
"modified_by": "Administrator",
"module": "Helpdesk",
"name": "HD Agent",
Expand Down
12 changes: 11 additions & 1 deletion helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ def users_present_in_team_assignment_rule(self):
return True

@frappe.whitelist()
def assign_agent(self, agent: str):
def assign_agent(self, agent):
availability = frappe.db.get_value("HD Agent", agent, "availability_status")

if availability == "Away":
frappe.throw("This agent is marked as Away and cannot be assigned tickets.")

Copy link
Member

@RitvikSardana RitvikSardana Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is not used anywhere, except apply_escalation_rule function, which is deprecated.

Copy link
Author

@Shindhu-Ramaswamy Shindhu-Ramaswamy Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixed in commit 910edf4

assign({"assign_to": [agent], "doctype": "HD Ticket", "name": self.name})

if frappe.session.user != agent:
Expand Down Expand Up @@ -558,6 +563,11 @@ def reply_via_agent(
medium = "" if skip_email_workflow else "Email"
subject = f"Re: {self.subject}"
sender = frappe.session.user
# Append agent signature if present
signature = frappe.db.get_value("HD Agent", {"user": sender}, "signature")
if signature and signature not in message:
message = f"{message}\n\n{signature}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems counter intuitive, we shouldn't do this.

We should show signature in the reply box in the ticket view, like as soon as an agent opens the reply box in the Ticket View, the signature should be displayed there.

This is how it should be displayed from the agent's signature

Image

Copy link
Author

@Shindhu-Ramaswamy Shindhu-Ramaswamy Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixed in commit 910edf4 — removed backend signature logic, moved to frontend in EmailEditor.vue"


recipients = to or self.raised_by
sender_email = None if skip_email_workflow else self.sender_email()

Expand Down
14 changes: 14 additions & 0 deletions helpdesk/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"on_trash": "helpdesk.extends.assignment_rule.on_assignment_rule_trash",
"validate": "helpdesk.extends.assignment_rule.on_assignment_rule_validate",
},
"ToDo": {
"before_insert": "helpdesk.overrides.assign.validate_agent_availability"
},
}

has_permission = {
Expand All @@ -75,6 +78,10 @@
"HD Ticket": "helpdesk.helpdesk.doctype.hd_ticket.hd_ticket.permission_query",
"HD Saved Reply": "helpdesk.helpdesk.doctype.hd_saved_reply.hd_saved_reply.permission_query",
}
permission_query_conditions.update({
"User": "helpdesk.overrides.assign.user_query_condition"
})


# DocType Class
# ---------------
Expand All @@ -99,3 +106,10 @@

before_tests = "helpdesk.test_utils.before_tests"
auth_hooks = ["helpdesk.auth.authenticate"]



link_query_conditions = {
"User": "helpdesk.overrides.assign.user_query_condition"
}

Empty file added helpdesk/overrides/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions helpdesk/overrides/assign.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import frappe
from frappe import _


def validate_agent_availability(doc, method=None):
if not doc.allocated_to:
return

status = frappe.db.get_value(
"HD Agent",
{"user": doc.allocated_to},
"availability_status",
)

if status == "Away":
frappe.throw(
msg=_("This agent is marked as Away and cannot be assigned tickets."),
title=_("Agent Unavailable"),
exc=frappe.ValidationError,
)
Comment on lines +21 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not throw error, we could do frappe.msgprint and frappe.log_error instead

coz let us say if a ticket was about to be created and then it got assigned to an agent who is unavailable, then the system will throw an error and the ticket will not be created. We should not block ticket creation process.

Copy link
Author

@Shindhu-Ramaswamy Shindhu-Ramaswamy Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixed in commit 910edf4 — replaced with frappe.msgprint and frappe.log_error"


def user_query_condition(user):
return """
EXISTS (
SELECT 1 FROM `tabHD Agent`
WHERE `tabHD Agent`.user = `tabUser`.name
AND `tabHD Agent`.availability_status = 'Available'
)
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed, you can remove this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixed in commit 910edf4 — removed the user_query_condition function"