logo

NJP

How to use Automatic Group Member Management

Import · Mar 16, 2021 · article

We uploaded our new application Automatic Group Member Management to the ServiceNow Share.

The app can be used to handle group memberships automatically based on certain conditions. The conditions can be either based on a user (e.g. Department = IT) or based on user references of a record (e.g. department head in department table). You also have the choice to write a script for the users who should be part of the group.

The app automatically adds new users which fulfill the conditions and delets users which do not fulfill the conditions anymore.

With the included member history you can audit the group memberships and build reports on the data.

Use Cases

Not sure why you could need the app? We currently use the app for the following standard use cases:

  • Put all Department Heads in one group
  • Put all Knowledge Base Owners and Manager in one group
  • Put all Cost Center Manager in one group
  • Put all Users from a certain location in one group

Key Features

In Version 1.1 the following key features exist:

  • Automatic user assignment to a group based oon
  • * user conditions
    • user references on a record (e.g. department head in department table)
    • scripted list of users
    • user list
    • group list
  • Addionaly restrict users based on user conditions (e.g. only active users)
  • Track added/deleted users for auditing
  • Script-API to start the evaluation process, e.g. from a Business Rule or Import Job

Initial Configuration

  1. Download the latest version from Share and install the update set in your instance.
  2. Allow Delete Access for Group Member Table
    1. Navigate to System >> Tables
    2. Open the table Group Member (sys_user_grmember)
    3. Open the tab Application Access and set Can delete to true.
    4. Save the record
    5. Your Application Access should now look like the following
      image

Create a Group Config

The Key Entry Point for the configuration is the module Group Configs. A group config defines the User Group and wether the member history should be tracked or not. You can run the Process directly from the record with the UI Action Run. If you want to test your configuration you can run Run Preview. The preview does not insert/delete any user from the group.

image

Create a Rule

To define which users should be part of the group you have to create rules for it. Every user who matches one rule will be added to the group.

The rules can be based on a record set with a user field or directly on the sys_user table.

The tab User Configuration can be used to to apply additional conditions on the users found by the record configuration (e.g. all Department Heads which are active).

image

[Optional] Configure the scheduled job

You can find the example scheduled job Process Active Group Configs in the Scheduled Script Executions. The scheduled job processes each active group config synchronously. You can copy the scheduled jobs and configure it as you wish.

[Optional] Use the Script API in your processes

The API x_msgfi_agmm.GroupProcessorAPI provides two functions

  • execute (groupConfig)
  • executeAsync (groupConfig)

The parameter groupConfig can be one of the following:

  • GlideRecord of the group config
  • SysID of the group config
  • Number of the group config
var api = x_msgfi_agmm.GroupProcessorAPI()
var runRecord = api.executeAsync('AGMM00001');
// runRecord is the GlideRecord of the Run Table (which stores information about the run)
View original source

https://www.servicenow.com/community/developer-articles/how-to-use-automatic-group-member-management/ta-p/2297365