feat: enhance agent profile with availability status and signature#3002
feat: enhance agent profile with availability status and signature#3002Shindhu-Ramaswamy wants to merge 8 commits intofrappe:developfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3002 +/- ##
===========================================
+ Coverage 50.78% 50.84% +0.06%
===========================================
Files 122 123 +1
Lines 5372 5381 +9
===========================================
+ Hits 2728 2736 +8
- Misses 2644 2645 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
helpdesk/overrides/assign.py
Outdated
| def user_query_condition(user): | ||
| return """ | ||
| EXISTS ( | ||
| SELECT 1 FROM `tabHD Agent` | ||
| WHERE `tabHD Agent`.user = `tabUser`.name | ||
| AND `tabHD Agent`.availability_status = 'Available' | ||
| ) | ||
| """ |
There was a problem hiding this comment.
this is not needed, you can remove this
There was a problem hiding this comment.
"Fixed in commit 910edf4 — removed the user_query_condition function"
| 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.") | ||
|
|
There was a problem hiding this comment.
this function is not used anywhere, except apply_escalation_rule function, which is deprecated.
| # 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}" |
There was a problem hiding this comment.
There was a problem hiding this comment.
"Fixed in commit 910edf4 — removed backend signature logic, moved to frontend in EmailEditor.vue"
| @@ -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" | |||
There was a problem hiding this comment.
Ensure that these are also shown in the "Profile" tab shown in "Settings Modal" both signature and status field
There was a problem hiding this comment.
"Fixed in commit 910edf4 — added both fields to Profile.vue"
| frappe.ui.form.on('HD Agent', { | ||
| refresh: function(frm) { | ||
| // Example: make status editable | ||
| frm.set_df_property('availability_status', 'read_only', 0); | ||
| } |
There was a problem hiding this comment.
removed the unwanted code
| if status == "Away": | ||
| frappe.throw( | ||
| msg=_("This agent is marked as Away and cannot be assigned tickets."), | ||
| title=_("Agent Unavailable"), | ||
| exc=frappe.ValidationError, | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
"Fixed in commit 910edf4 — replaced with frappe.msgprint and frappe.log_error"
|
@RitvikSardana I have made the requested changes. Kindly review and let me know your feedback. |
| <FormControl | ||
| class="w-full md:col-span-2" | ||
| type="textarea" | ||
| :label="__('Signature')" | ||
| v-model="profile.signature" | ||
| /> |
There was a problem hiding this comment.
this should be a TextEditor component
| availabilityStatus: data.availability_status, | ||
| signature: data.signature, |
desk/src/components/EmailEditor.vue
Outdated
| try { | ||
| const res = await getSignature.fetch(); | ||
| signature = res?.signature || ""; | ||
| } catch (err) { |
There was a problem hiding this comment.
no need to do this, we already fetch some user details, get it from there.
desk/src/components/EmailEditor.vue
Outdated
| } | ||
|
|
||
| function addToReply( | ||
| async function addToReply( |
helpdesk/overrides/assign.py
Outdated
| 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.msgprint( | ||
| msg=_("This agent is marked as Away "), | ||
| title=_("Agent Unavailable"), | ||
| ) | ||
| frappe.log_error("Ticket assigned to Away agent", "Agent Unavailable") |
There was a problem hiding this comment.
check how assignment rule is being applied for reference
|
@RitvikSardana i had made the changes in the code . please review and let me know your feedback |



1.Agent Availability Status
Introduced an Availability Status field for agents (e.g. Available / Away).
This allows the system to clearly distinguish agents who are currently available to take tickets.
Added a Signature field to the HD Agent doctype.
This can be used in ticket responses and communications.
When assigning a ticket:
Only available agents are shown in the Assign To dropdown.
Prevents accidental assignment to away agents.
If an agent is marked as Away, a warning popup is shown during assignment.
Implemented a custom assign_to_conditions override to ensure:
Agent filtering is enforced at the backend level.
Only agents with availability status = Available are returned in assignment queries.
#issue #2872 – Enhance Agent’s Profile
I completed the corrections .