We have the concept of Team Lead in ServiceNow. These people get notifications of all new tickets added to the queue for that particular group.
Maintaining these is annoying, especially because many groups simply want their Team Lead lists to match the set of members for the group. We already have Active Directory to help us maintain the group memberships, but we had no programmatic way to maintain Team Lead Lists. Now we do.
Set a single group Team Leads to match the set of Team Members for that group
Set the GroupName to the group you wish to modify, and then run this as a background script.
var groupName='INF Unix Systems'; // set groupName to the group where you want to synchronize team leads to be the same // as the set of all members of the group // this is especially useful for CTS STC groups var gr1 = new GlideRecord('sys_user_group'); gr1.addQuery('name',groupName); gr1.query(); while ( gr1.next() ) { gs.log("group name: "+ gr1.name + " and group full name: " + gr1.u_full_name + " and sys_id: " + gr1.sys_id); gs.log("ORIGINAL group u_team_leads: " + gr1.u_team_leads); var leadsString=''; var gr2 = new GlideRecord('sys_user_grmember'); gr2.addQuery('group',gr1.sys_id); gr2.query(); while ( gr2.next() ) { // gs.log("user sys_id is: " + gr2.user); if ( leadsString.length > 0 ) { leadsString+=','; } leadsString+=gr2.user; } gs.log("PROPOSED group leads: " + leadsString); var gr3 = new GlideRecord('sys_user_group'); gr3.addQuery('name',groupName); gr3.query(); while (gr3.next()){ gr3.u_team_leads = leadsString; gr3.update(); } var gr4 = new GlideRecord('sys_user_group'); gr4.addQuery('name',groupName); gr4.query(); while (gr4.next()){ gs.log("UPDATED group u_team_leads: " + gr4.u_team_leads); } }
Maintain all CTS STC group team lead lists in one step
This is tempting, but dangerous. There are at least twelve groups I needed to apply this to in January 2013 and they all started out CTS STC. However, there are twenty four groups that start out CTS STC, so I would have broken groups that should NOT have all members be team leads. So this script could be useful if group name input is tested manually to be certain it wasn't going to affect unintended groups before setting the script loose.
A safe list to cover just the twelve groups, as of Jan 2013; this should be rechecked each semester as groups get renamed:
CTS STC B
CTS STC Grad
CTS STC Old Campus
CTS STC S
CTS STC T
The next ones don't get any easier using the startsWith script because either there are no other common letter groups, or we cannot use a single letter to ease our typing because we will stomp other groups with the common beginning letter
CTS STC Calhoun
CTS STC Davenport
CTS STC Ezra Stiles
CTS STC Jonathon Edwards
CTS STC Morse
CTS STC Pierson
var groupStartsWith = 'CTS STC Old Campus'; var gr0 = new GlideRecord('sys_user_group'); gr0.addQuery('name','STARTSWITH',groupStartsWith); gr0.query(); while ( gr0.next() ) { gs.log("group name: "+ gr0.name); var groupName=gr0.name; // set groupName to the group where you want to synchronize team leads to be the same // as the set of all members of the group // this is especially useful for CTS STC groups var gr1 = new GlideRecord('sys_user_group'); gr1.addQuery('name',groupName); gr1.query(); while ( gr1.next() ) { gs.log("group name: "+ gr1.name + " and group full name: " + gr1.u_full_name + " and sys_id: " + gr1.sys_id); gs.log("ORIGINAL group u_team_leads: " + gr1.u_team_leads); var leadsString=''; var gr2 = new GlideRecord('sys_user_grmember'); gr2.addQuery('group',gr1.sys_id); gr2.query(); while ( gr2.next() ) { // gs.log("user sys_id is: " + gr2.user); if ( leadsString.length > 0 ) { leadsString+=','; } leadsString+=gr2.user; } gs.log("PROPOSED group leads: " + leadsString); var gr3 = new GlideRecord('sys_user_group'); gr3.addQuery('name',groupName); gr3.query(); while (gr3.next()){ gr3.u_team_leads = leadsString; gr3.update(); } var gr4 = new GlideRecord('sys_user_group'); gr4.addQuery('name',groupName); gr4.query(); while (gr4.next()){ gs.log("UPDATED group u_team_leads: " + gr4.u_team_leads); } } }