Replace group with a new one

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago - last edited 9 hours ago
Hi all,
Lately we've been splitting some of our groups into smaller groups. One of the problems that we're experiencing is finding all the areas where a group was being used and updating it to the new group. For example, we have found the old group associated with ticket assignments, flows, approvals, notifications, reports, scheduled reports, configuration items, and more.
Is there any way to query all the records that a certain group is referenced in? I was thinking of using related lists on the sys_user_group table, but given that there's 8,000 of them, that's not realistic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Below code to retrieve all unique records from tables that extend the task table, and for each record, I want to extract:
Record Number
Assignment Group
Approval Group
Table Name
I limit the output to 5 records only, you can update the script to include a counter and stop after 5 records are collected.
var resultList = [];
var maxResults = 5;
var resultCount = 0;
// Get all tables extending from Task
var tableGR = new GlideRecord('sys_db_object');
tableGR.addQuery('super_class.name', 'task');
tableGR.query();
while (tableGR.next() && resultCount < maxResults) {
var tableName = tableGR.getValue('name');
gs.print('Checking table: ' + tableName);
var gr = new GlideRecord(tableName);
if (!gr.isValid()) {
gs.print('Skipping invalid table: ' + tableName);
continue;
}
gr.query();
while (gr.next() && resultCount < maxResults) {
var assignmentGroup = gr.isValidField('assignment_group') ? gr.assignment_group.getDisplayValue() : '';
var approvalGroup = gr.isValidField('approval_group') ? gr.approval_group.getDisplayValue() : '';
var number = gr.getValue('number') || gr.getDisplayValue('sys_id');
// Skip if both fields are empty
if (!assignmentGroup && !approvalGroup) continue;
resultList.push({
table: tableName,
number: number,
assignment_group: assignmentGroup,
approval_group: approvalGroup
});
resultCount++;
}
}
// Output results
gs.print('Results:\n');
for (var i = 0; i < resultList.length; i++) {
var r = resultList[i];
gs.print(r.table + ' | ' + r.number + ' | Assignment: ' + r.assignment_group + ' | Approval: ' + r.approval_group);
}
Output:
*** Script: Checking table: gsw_task
*** Script: Checking table: sys_report_access_request
*** Script: Checking table: orphan_ci_remediation
*** Script: Checking table: incident
*** Script: Results:
*** Script: incident | INC0000060 | Assignment: Network | Approval:
*** Script: incident | INC0000009 | Assignment: Service Desk | Approval:
*** Script: incident | INC0000010 | Assignment: Database | Approval:
*** Script: incident | INC0000011 | Assignment: Hardware | Approval:
*** Script: incident | INC0000012 | Assignment: Database | Approval:
You can customize the above script based on your need .
Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago - last edited 9 hours ago
Hi @DylanBlumenberg,
I don't think there's an easy way for this..
My suggestion is to check the [sys_update_xml] but it's table with all the records in all update sets, so perhaps it's better to access it "sys_update_xml.filter" and press enter, it will load an empty table with no records, you apply the desired condition and then you query it. But for this you will need to know the group's sys_id, so if you have multiple groups it will be still difficult...
Another thing is to search for this using SN Utils browser extension, either slashcommand "/<sys_id>" and/or "/code <sys_id>". That can also put some lights into it.
And last, to go to Update Jobs but you will need one update job per table (e.g. one for Task, one for KB, one for CMDB, etc...) which is also quite lengthy 😕
How many groups are you going to replace, just one or several?
EDIT (orange): the slashcommand /sys_id will just open the record which will not help you :))
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */