Clear Assigned to on Assignment Group Change in Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 12:16 AM
Hello All,
We have a Requirement where we want to assign multiple tickets to an Assignment Group in ServiceNow and on assigning the "Assigned To" field should clear.
We have the same functionality in Incident Default view and we have tried replicating the Client Script and Script Include for the Agent Workspace. by changing the view of the Client Script to the "workspace" view.
Does not seem to work.
Client Script
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Call function to clear assigned to
var ga = new GlideAjax('ClearAssignedTo');
ga.addParam('sysparm_name', 'clearfield'); // Always try to use asynchronous (getXML) calls rather than synchronous (getXMLWait)
ga.addParam('sysparm_sys_ids', sysIDs);
alert(sysIDs);
ga.getXML(parseResponse);
function parseResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
callback(saveAndClose);
}
Script Include
var ClearAssignedTo = Class.create();
ClearAssignedTo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
clearfield: function() {
var grTask = new GlideRecord("incident");
var incTasks = this.getParameter('sysparm_sys_ids').split(',');
for (i = 0; i < incTasks.length; i++) {
grTask.get(incTasks[i]);
if (grTask.assigned_to != '') {
grTask.assigned_to = '';
grTask.update();
}
}
},
type: 'ClearAssignedTo'
});
Sharing the SS of the Configurations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:24 AM
@Ankur Bawiskar we have also tried these snippets on a PDI. They are working well for the ITIL view.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:27 AM
you are updating the sysIds selected.
Is the update not happening?
the answer in alert should not be a concern
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:36 AM - edited 07-26-2023 02:38 AM
var grTask = new GlideRecord("incident"); var incTasks = this.getParameter('sysparm_sys_ids').split(','); for (i = 0; i < incTasks.length; i++) { grTask.get(incTasks[i]); if (grTask.assigned_to != '') { grTask.assigned_to = ''; grTask.update();
Hey @Ankur Bawiskar ,
We receive the sys id's of the incidents that are being edited,
we glide to the individual records using the sys id's and then we check whether the 'assigned to' field is empty or not.
if the fields are empty, we move to the next record,
else if the filed is not empty, we clear the value.
The Update is happening in the itil view but these scripts are not working for the Agent Workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 03:06 AM
so are you saying in agent workspace the glide record is not updating?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 03:20 AM
For Agent workspace even the client script is not triggering.