- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 03:05 AM
Hi Guys/Girls.
I know this is possible as it was set up like this in my old job but only been working with Service Now admin for a few weeks now so still very new to all of these java scripts etc.
Anyway, In an active incident, if the incident is re-assigned from one Assignment group to another, I want it to automatically remove the Assigned To user. At the moment, we're receiving incidents back from 2nd Line IT to the Service Desk and the incident is still showing as assigned to their engineers (which aren't even in the Service Now assignment group to begin with!)
Any advice would be really appreciated. I would imagine I have to create a Client Script of some sort, possibly onCellEdit or onChange but not sure which and not sure what content to include.
Thanks a lot.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 05:17 AM
Hi Mark,
I think I understand your requirement now.
If you want the script to only run on existing Incidents (records which have been saved at least once), you could use:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if(!g_form.isNewRecord()){ // clear assigned_to because assignment group just changed, on an existing record
g_form.clearValue('assigned_to');
}
}
However, if you don't want the value to be cleared for the Service Desk users, you might need some more specific logic. For example, you could check which group has been selected, and then decide if you want to clear the Assigned To. The code below checks the display value of the Assignment Group, and bypasses the clearValue if the group display name is "Service Desk".
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var groupName = '';
if(g_form.getDisplayBox('assignment_group')) groupName = g_form.getDisplayBox('assignment_group').value; // get display value of group
if(!g_form.isNewRecord() && groupName!='Service Desk'){ // clear assigned_to because assignment group just changed to something other than Service Desk, on an existing record
g_form.clearValue('assigned_to');
}
}
Let me know if this works for you?
Regards,
Jake

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 04:55 AM
Hi Mark,
I'm not sure I understand your requirement completely. The script I pasted will clear the Assigned To field only when the Assignment group is changed to another group other than the group that was there when that user was assigned (excluding clearing the group). If the engineer was the Assigned To user, and the Assignment Group was "2nd Level", then you change the group to "Service Desk", this should clear the Engineer from the Assigned To field.
Are you saying you want the Assigned To field cleared only for specific transitions betweens groups? e.g from 2nd Level to Service Desk?
Regards,
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 05:04 AM
Thanks again Jake.
You were definitely correct the first time, I need to make it so the engineer's name clears when the assignment group is changed from 2nd Line to Service Desk. However with the script in place now, even when Service Desk are logging new calls they can't assign anything to themselves after putting "Service Desk" in the assignment group because it's removing their names as soon as they put them into "Assigned To"
Sorry if I'm not explaining very well. I'm sure there must be some other condition we need to add to this script but I can sense we're almost there
Thanks again.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 05:17 AM
Hi Mark,
I think I understand your requirement now.
If you want the script to only run on existing Incidents (records which have been saved at least once), you could use:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if(!g_form.isNewRecord()){ // clear assigned_to because assignment group just changed, on an existing record
g_form.clearValue('assigned_to');
}
}
However, if you don't want the value to be cleared for the Service Desk users, you might need some more specific logic. For example, you could check which group has been selected, and then decide if you want to clear the Assigned To. The code below checks the display value of the Assignment Group, and bypasses the clearValue if the group display name is "Service Desk".
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var groupName = '';
if(g_form.getDisplayBox('assignment_group')) groupName = g_form.getDisplayBox('assignment_group').value; // get display value of group
if(!g_form.isNewRecord() && groupName!='Service Desk'){ // clear assigned_to because assignment group just changed to something other than Service Desk, on an existing record
g_form.clearValue('assigned_to');
}
}
Let me know if this works for you?
Regards,
Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 05:19 AM
Mark, based on your last message, you're saying that as soon as the user types into the Assigned To box, the value is immediately cleared again? If so, this sounds like in the client script, you have set the Field Name to Assigned To, which should be Assignment Group. If Not, can you paste a screenshot of your script please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 06:06 AM