Update Group Managers

Pritu
Tera Contributor

A script needs to be written to update group manager for servicenow groups in sys_user_group.list table 

2 REPLIES 2

Harish Bainsla
Kilo Patron
Kilo Patron

var groupName = "YourGroupName"; // Replace with the name of the group you want to update.
var newManager = "NewManagerUserID"; // Replace with the sys_id of the new manager user.


var group = new GlideRecord("sys_user_group");
if (group.get("name", groupName) && newManager) {
// Set the new manager for the group.
group.setValue("manager", newManager);
group.update();

gs.print("Group manager updated successfully.");
} else {
gs.print("Group not found or invalid manager user.");
}

Hi Harish,

Thanks for your suggestion. But we need to update multiple group managers in multiple groups (sys_user_group.list) table