preventing Inactive Groups from being assigned incidents

SteveS
Kilo Expert

We have an org change and we are deactivating groups as needed. The problem I am running into is that we have a client script ((BP) Set Assignment Group to ci) that populates the assignment group field whether or not the group is active or not.

Client Script: (BP) Set Assignment Group to ci

function onChange(control, oldValue, newValue, isLoading) {
if(!isLoading && document.getElementById('incident.assignment_group')){
if (newValue == '') {
g_form.setValue('assignment_group', '');
}
if (newValue != oldValue) {
var ci = g_form.getValue('cmdb_ci');
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_id', ci);
gr.query();
if (gr.next()) {
g_form.setValue('assignment_group', gr.support_group);
}
}
}


Does anyone have any idea on how to update this script so that if the assignment_group.active == false set the assignment group to a specific group, else keep the assignment group = gr.support_group

4 REPLIES 4

Chuck Tomasi
Tera Patron

I recommend doing a lookup on the retrieved group and checking the active state before updating the assignment group field.


This is obvious that new incidents can't be assigned , If predictive intelligent system is doing that then it's  means this should be fixed at product level. There can be a checkbox in settings to control that behaviour.

MB26
ServiceNow Employee
ServiceNow Employee

It could look something like this



function onChange(control, oldValue, newValue, isLoading) {
if(!isLoading) {
if (newValue == '') {
g_form.setValue('assignment_group', '');
}
if (newValue != oldValue) {
var ci = g_form.getValue('cmdb_ci');
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_id', ci);
gr.query();
if (gr.next()) {
var sgrp = gr.support_group;
var grp = new GlideRecord("sys_user_group");
if (grp.get(sgrp)) {
if (grp.active == 'true'){
g_form.setValue('assignment_group', gr.support_group);
}
else {
g_form.setValue('assignment_group', gr.change_control);
}
}
}
}
}
}


The gr.change_control is just another group field that I used to test this. You could set any other group there.


that did it, thank MB