poyntzj
Kilo Sage

We have 2 distinct domains in our environment.   An internal one and an external one.

Both are used for ESS users, but also our process users and our 3rd party partners.

Occasionally, some of our 3rd party partners use our Servicenow for working on tickets and need tickets assigning to them.

All our users and groups are imported on a regular basis.   Part of the group process removes all the group members and then readds the members as they are at the time of import.

When we import our users or groups from the EXT domain, we prefix with either EXT\ (users) or just EXT (groups)   for easy identification

Until now, all the EXT- Groups have been linked to an internal group by using the Parent feature on the Group record

We decided to do this as it is easier for most engineers to see one group that may cover SQL or WEB instead of an internal and external one.

find_real_file.png

When assigning a ticket to the group, we have to Expand the parent group and then choose the child group.

From there, the group manger(s) or assigners can assign a ticket or the engineer can assign it to themselves.

No great issues, though a little cumbersome as it is not as easy as typing in the group name and looking up.

A new group coming on board also has internal and external users, but they wanted all the users to appear in a single group.

Due to our imports and the clearing of groups, it is not straight forward, and security etc prevents these users from having an internal user account.

I therefore decided to add a new onAfter script to the transform maps for internal groups.   After processing the target group and the target groups' members, it looks at the groups table for any child groups.   If it finds any child groups, it will then add the child groups members to the target groups member list.

This satisifes the request from this group and to be honest, makes it a little easier ot assign tickets between teams

the onAfter script is as follows.

(function(){

      var recID = target.getValue('sys_id');

      var strGrpName = target.getValue('name');

      //gs.log('Processing : ' + recID + ' : ' + strGrpName);

      // Query the groups and get any groups where the parent is the current group

      var suggr = new GlideRecord('sys_user_group');

      suggr.addQuery('parent',recID);

      suggr.query();

      while (suggr.next())

      {

              //gs.log('Sub member of ' + strGrpName + ' is : ' + suggr.name);

              // now we have groups where the parent is our current group, lets

              // get some users info

              var sugmgr = new GlideRecord('sys_user_grmember');

              sugmgr.addQuery('group',suggr.sys_id);

              sugmgr.query();

              while (sugmgr.next())

              {

                      //gs.log('Member of ' + suggr.name + ' is : ' + sugmgr.user.getDisplayValue());

             

                      // now to see if we have any records for the user in the parent group

                      var sugmgr2 = new GlideRecord('sys_user_grmember');

                      sugmgr2.addQuery('group', recID);

                      sugmgr2.addQuery('user',sugmgr.user);

                      sugmgr2.query();

                      if (!sugmgr2.next())

                      {

                              gs.log('Adding : ' + sugmgr.user.getDisplayValue() + ' to group : ' + strGrpName);

                              sugmgr2.initalize();

                              sugmgr2.group = recID;

                              sugmgr2.user = sugmgr.user;

                              sugmgr2.insert();

                      }

              }

      }

             

})();