Update assignment groups in bulk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2019 07:01 AM
Morning!
Looking for assistance with a script (Background script) that will allow me to update multiple assignment groups at one time.
I need to query the task table so that I can find all records assigned to assignment group X, and then reassign / setValue to Assignment group Y.
I need to do this via a background script as, i need to not fire notifications or effect the updated fields. Assuming i iwll need to leverage the autoSysFields (False); and setWorkflow (false) ; options.
any assistance with this query/script would be greatly appriciated
Thanks!
- Labels:
-
Best Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2019 07:20 AM
Hi,
Unfortunately, I think the notifications will send UNLESS they are triggered by events from BRs...which can be prevents through using lines such as:
gr.autoSysField(false); // so that the records don't have system updates
gr.setWorkflow(false); // so no business rules are run
So...you'd need to most likely temporarily turn off this notification by making it inactive, running your script, then turning it back on, would be my suggestion.
var gr = new GlideRecord('incident');
gr.addQuery('assignment_group', 'sys_id of group');
gr.query();
while (gr.next()) {
gs.print(gr.number);
}
This will print all the records so you can verify before you go and start changing stuff.
If it all looks good, remove gs.print line and add in:
gr.setValue('assignment_group','sys_id of new group');
gr.autoSysField(false);
gr.setWorkflow(false);
gr.update();
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2019 07:36 AM
Hello,
Please find the script inline...
Always run on pre production instances to make sure that everything is working fine. Only in london we have the option of rolling back background scripts
var gr = new GlideRecord('task');
gr.addQuery('assignment_group', 'sys_id of the existing group');
gr.query();
while (gr.next()) {
gr.setValue('assignment_group','sys_id of updated group');
gr.autoSysFields(false); //in the above post i dont see "fields" its autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Hope this helps
Mark this response as correct if that really helps
As we used setWorkflow to false it wont run BR which helps in stopping event triggers but general notifications configured cannot be triggered either you can inactivate the notifications for a while or you can selectively select the user table and add the notification field and disable the notifications for those users for a particular amount of time
Thanks,
Siva
Thanks,
Siva