From 7700f4b262cc29c9a280ec8ea1b1cf1159cbb173 Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:27:23 +0530 Subject: [PATCH 1/2] Code.js --- .../code.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Server-Side Components/Script Includes/Incident assigned count to assigned to user/code.js diff --git a/Server-Side Components/Script Includes/Incident assigned count to assigned to user/code.js b/Server-Side Components/Script Includes/Incident assigned count to assigned to user/code.js new file mode 100644 index 0000000000..df6400cede --- /dev/null +++ b/Server-Side Components/Script Includes/Incident assigned count to assigned to user/code.js @@ -0,0 +1,16 @@ +var assignedtochange = Class.create(); +assignedtochange.prototype = Object.extendsObject(AbstractAjaxProcessor, { + + assigned: function(){ + var assign = this.getParameter('sysparm_assign'); + var inc = new GlideRecord('incident'); + inc.addQuery('assigned_to', assign); + inc.query(); + while(inc.next()) { + var count = inc.getRowCount(); + return count; + } + }, + + type: 'assignedtochange' +}); From 301ad73f21649300cf9be45d40e5691aa4a8d458 Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:37:18 +0530 Subject: [PATCH 2/2] ReadMe.md --- .../ReadMe.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Server-Side Components/Script Includes/Incident assigned count to assigned to user/ReadMe.md diff --git a/Server-Side Components/Script Includes/Incident assigned count to assigned to user/ReadMe.md b/Server-Side Components/Script Includes/Incident assigned count to assigned to user/ReadMe.md new file mode 100644 index 0000000000..a894307543 --- /dev/null +++ b/Server-Side Components/Script Includes/Incident assigned count to assigned to user/ReadMe.md @@ -0,0 +1,35 @@ +>**Create a Client-Callable Script Include** + +1. Develop a Script Include (assignedtochange) that extends AbstractAjaxProcessor. + +2. The Script Include should accept a parameter (the user’s sys_id) passed from a Client Script. + +3. It will query the Incident (incident) table to count how many records are assigned to that user. + +4. Return the count to the client. + +>**Create a Client Script** + +1. From the Incident form, the Client Script will call the Script Include using GlideAjax. + +2. Pass the Assigned to user’s sys_id as a parameter. + +3. Display or use the returned Incident count on the client side (e.g., show a message or populate a field). + + Ex. + function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + + //Type appropriate comment here, and begin script below + var aj = new GlideAjax('assignedtochange'); + aj.addParam('sysparm_name', 'assigned'); + aj.addParam('sysparm_assign', newValue); + aj.getXMLAnswer(answer); + + function answer(response) { + alert ("Assigned to has already been an part of " + response + " Incidents"); + } + + }