Skip to content

Commit 04a068c

Browse files
authored
Create clientScript.js
1 parent 9f72ba5 commit 04a068c

File tree

1 file changed

+31
-0
lines changed
  • Client-Side Components/Client Scripts/Display Incident Count of Assigned-To User When Field Changes

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
if (isLoading || newValue === '') return;
3+
4+
// Clear any previous messages
5+
g_form.clearMessages();
6+
7+
// Create GlideAjax object to call the Script Include
8+
var ga = new GlideAjax('IncidentAssignmentCheck');
9+
ga.addParam('sysparm_name', 'getIncidentCount');
10+
ga.addParam('sysparm_user', newValue);
11+
12+
13+
ga.getXMLAnswer(function(response) {
14+
var count = parseInt(response, 10);
15+
16+
17+
if (isNaN(count)) {
18+
g_form.addErrorMessage("Could not retrieve open incident count.");
19+
return;
20+
}
21+
22+
var userName = g_form.getDisplayValue('assigned_to');
23+
var msg = userName + " currently has " + count + " incidents assigned ";
24+
25+
if (count >= 5) {
26+
g_form.addInfoMessage(msg + " Please review workload before assigning more incidents");
27+
} else {
28+
g_form.addInfoMessage(msg);
29+
}
30+
});
31+
}

0 commit comments

Comments
 (0)