How to add an assignment group "type" to the Type field?

Laurie Marlowe1
Kilo Sage

Hello,

I am trying to write a script to add a "Type" to all our assignment groups.  I want to add the "Westar" type to the Type field for all existing assignment groups.

find_real_file.png

I'm not sure how to code to add the "Westar" type into the List Collector:

var t = new GlideRecord('sys_user_group');
t.setLimit(1);
t.addQuery('u_assignment_group', true);
t.query();
while(t.next()){
t.type = 'Westar';
gs.print(t.number);
}

Thank you in advance!

 

Laurie

 

 

1 ACCEPTED SOLUTION

Jay81
Tera Guru

Please try below script.

 

var grp = new GlideRecord('sys_user_group');
grp.query();
while(grp.next())
{
grp.type = grp.type + ",1cb8ab9bff500200158bffffffffff62"; // replace with Westar sys_id
grp.update();
}

View solution in original post

8 REPLIES 8

There is a list of values in the Group Type list collector.  I am trying to add one of the Group Types to all of the groups.  We are going through a merger and want to be able to distinguish between exiting groups, and new groups for the new company.  We do not want to use "smart names" for the group name, and later have to update all the names, once the dust settles.

find_real_file.png 

That didn't answer most of my questions, but I think my reply should still get you what you're looking for. 

Jay81
Tera Guru

Please try below script.

 

var grp = new GlideRecord('sys_user_group');
grp.query();
while(grp.next())
{
grp.type = grp.type + ",1cb8ab9bff500200158bffffffffff62"; // replace with Westar sys_id
grp.update();
}

Run above script as background script.