Group manager update

Ankitha4
Tera Contributor

Can anyone help me how can we update the group manager of a group in sys_user_group table for multiple.records using script

6 REPLIES 6

Mark Manders
Mega Patron

That all depends on your requirement. Do you need to update multiple records with the same new manager? Do you need logic to select manager a, replacing with b and manager c with d? 

Is this something to run one time, or regularly (automated)? 

Based on the limited information, this is the script:

var group = new GlideRecord('sys_user_group');
group.addQuery('your_query_to_select_the_group(s)');
group.query();
while(group.next()){
group.setValue('manager','sys_id_of_new_manager');
group.update();
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi mark , thanks for the reply .

We need to update the multiple group records with different group managers and for now it is for one time run . Can you please suggest if there is any script for that

@Ankitha4,

 

Do you need to do this via a script? What number are of changes or variations are we looking at.

I often find using the list edit and 'Update Selected' option far easier, quicker and 'safer' to update.

You can either cherry pick records, or you can use the filter to search for you record set and 'Update All'.

 

Screenshot 2024-08-12 at 11.24.30.png

 

@Ankitha4 To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

In that case you have to explain your logic, or just do a manual 'update all' action. Because without knowing your logic, the only answer will be: use the script I already provided and put a lot of 'if/else' in there.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark