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); +} 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. 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"); + } + + } 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' +});