Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Fix script to change a group in the incident form

josenava
Tera Expert

Hello everyone, 

Please need your help creating a fix script that will change the assignment group from the current one to a different one from the beginning of time, I have been checking scripts but the ones I have found are just to update last year's.

This script I took it from sachin.namjoshi

var inc = new GlideRecord('incident');
inc.addEncodedQuery('sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()');
inc.query();
while(inc.next()){

inc.assignment_group = "d625dccec0a8016700a222a0f7900d06";
inc.update();

}

what do I need to modify so that it changes all incidents?

Thank you

1 ACCEPTED SOLUTION

Updated script below. Please update line no 2 with the exact sysid of the Service Desk group.

var inc = new GlideRecord('incident');
inc.addQuery('assignment_group','PASS Service Desk SYSID HERE'); //Replace PASS Service Desk SYSID HERE with the sysid of the Service Desk group
inc.query();
while(inc.next()){

inc.assignment_group = "d625dccec0a8016700a222a0f7900d06"; //Assume this is the SYSID of SD alert group

inc.setWorkflow(false); //Disables the running of business rules that might normally be triggered by subsequent actions.
inc.update();

}

View solution in original post

10 REPLIES 10

Mike Patel
Tera Sage

try below. NOTE: This will change assignment group on all incidents. if you want to change assignment group of specific group to new group then we can add inc.addQuery('assignment_group', 'OLD_GROUP_SYS_ID');

var inc = new GlideRecord('incident');
inc.addQuery('assignment_group', '!=', 'd625dccec0a8016700a222a0f7900d06');
inc.query();
while(inc.next()){
	inc.assignment_group = "d625dccec0a8016700a222a0f7900d06";
	inc.update();	
}

Hello Mike, 

Thank you yes I need to change just the incidents assigned to "Service Desk" to "SD alert" 

 

So the code would be like this right?

var inc = new GlideRecord('incident');
inc.addQuery('assignment_group','OLD_GROUP_SYS_ID');
inc.query();
while(inc.next()){
inc.assignment_group = "GROUP_NAME";
inc.update();
}

Yes, this should work.