Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Display Info Message of Incident Count of Assigned-To User When Field Assigned-To Changes

Displays a message showing the count of **open incidents** assigned to a user whenever the **Assigned To** field changes on the Incident form.

- Helps assess the assignee’s **current workload** by fetching and displaying active incident counts (excluding *Resolved*, *Closed*, and *Canceled* states)
- Shows an **info message** with the count of the assignee's assigned incidents
- Uses an **onChange Client Script** on the **Assigned To** field and a **GlideAjax Script Include** called from the client script to fetch the count dynamically

---

### Info Message Example 1
![Incident_Count_message_1](Incident_Count_message_1.png)

### Info Message Example 2
![Incident_Count_message_2](Incident_Count_message_2.png)

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') return;

// Clear any previous messages
g_form.clearMessages();

// Create GlideAjax object to call the Script Include
var ga = new GlideAjax('IncidentAssignmentCheck');
ga.addParam('sysparm_name', 'getIncidentCount');
ga.addParam('sysparm_user', newValue);


ga.getXMLAnswer(function(response) {
var count = parseInt(response, 10);


if (isNaN(count)) {
g_form.addErrorMessage("Could not retrieve open incident count.");
return;
}

var userName = g_form.getDisplayValue('assigned_to');
var msg = userName + " currently has " + count + " incidents assigned ";

if (count >= 5) {
g_form.addInfoMessage(msg + " Please review workload before assigning more incidents");
} else {
g_form.addInfoMessage(msg);
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var IncidentAssignmentCheck = Class.create();
IncidentAssignmentCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getIncidentCount: function() {
var user = this.getParameter('sysparm_user');
var count = 0;

if (user) {
var gr = new GlideAggregate('incident');
gr.addQuery('assigned_to', user);
gr.addQuery('state', 'NOT IN', '6,7,8');
gr.addAggregate('COUNT');a
gr.query();

if (gr.next()) {
count = gr.getAggregate('COUNT');
}
}
return count;
},

type: 'IncidentAssignmentCheck'
});
Loading