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/4] 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/4] 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"); + } + + } From b6d88ea751931167c5eba471645bfcbc79e2ab5b Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:03:04 +0530 Subject: [PATCH 3/4] ReadMe.md --- .../Add Loggedin user as Incident assigned to/ReadMe.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/ReadMe.md diff --git a/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/ReadMe.md b/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/ReadMe.md new file mode 100644 index 0000000000..185cfb6754 --- /dev/null +++ b/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/ReadMe.md @@ -0,0 +1,3 @@ +>**UI Action** + +When a new Incident record is created, provide a UI Action (button) labeled “Assign to Me” so that the logged-in user can quickly assign the Incident to themselves. From 74d4c48423b0b09a28fcbf0f058daa5d60d900fd Mon Sep 17 00:00:00 2001 From: chaytarak <62869669+chaytarak@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:03:58 +0530 Subject: [PATCH 4/4] Code.js --- .../Code.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/Code.js diff --git a/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/Code.js b/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/Code.js new file mode 100644 index 0000000000..b4a5149f41 --- /dev/null +++ b/Client-Side Components/UI Actions/Add Loggedin user as Incident assigned to/Code.js @@ -0,0 +1,12 @@ +var currentUser = gs.getUserID(); //Getting loggedIn User Id + +//Checing wheather user is available or not in Assignee field +if(current.assigned_to == ""){ + current.assigned_to = currentUser; //Setting the current loggedIn user + current.update(); //updating the record. + gs.addInfoMessage("Incident has been assigned to You."); + action.setRedirectURL(current); +} else { + gs.addErrorMessage("Incident is already assigned"); + action.setRedirectURL(current); +}