The SCIM2ClientUtil API provides utility methods to obtain the unique identifiers of external provider systems and then use that information when calling the SCIM2Client API.

This API runs in the sn_auth namespace and requires the SCIM v2 - ServiceNow Cross-domain Identity Management Client (com.snc.integration.scim2.client) plugin to be installed to access the API.

For additional information on SCIM, see System for Cross-domain Identity Management (SCIM).

SCIM2ClientUtil - getProviderIdByFilter(String provider, String resourceName, String filter)

Returns the unique identifier of a specified resource from a specified external provider system for a unique resource ID in a ServiceNow instance using a filter expression to describe the desired resource.

This API is useful when mapping ServiceNow fields to SCIM fields where the resource identifier in the external provider system is needed. Before calling this method, a unique field must be defined for the resource in the system attribute map, located in the SCIM Provider Resource Mapping [sys_scim_provider_resource_mapping ] table.

For additional information on provider resource mapping, see Create a SCIM Provider Resource Mapping.

Table 1. Parameters
Name Type Description
provider String Name of the configured SCIM service provider.

Table: In the name field of the SCIM Provider [sys_scim_provider] table.

resourceName String Name of the resource type, such as User or Group.

Table: In the resource_name field of the SCIM Provider Resource Mapping [sys_scim_provider_resource_mapping] table.

filter String Filter expression to apply to the return results.

For additional information on the available filter parameters and their associated format, refer to the following section in the Internet Engineering Task Force document: System for Cross-domain Identity Management: Protocol

https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2

Table 2. Returns
Type Description
String Unique resource identifier used by the external service provider.

Throws an exception if there is any problem while fetching the information.

Example

The following example shows how to obtain the resource identifier of the user using the filter 'username eq "abel.tuter"'.

var response = sn_auth.SCIM2ClientUtil.getProviderIdByFilter('SNOW Provider','User','username eq "abel.tuter"'); 
gs.info('response: ' + response);

Output:


 "005d500b536073005e0addeeff7b12f4"

Example

The following example shows how to use a script to obtain the resource identifier of the manager using the filter 'userName eq "' + manager + '"'.

(function getValue(resourceGR) {
  try {
    var manager = resourceGR.manager.user_name;
    return sn_auth.SCIM2ClientUtil.getProviderIdByFilter('SCIM Provider Demo', 'User', 'userName eq "' + manager + '"');
  } catch (e) {
    gs.error('Unable to get attribute value using script' + e);
    // Handle failure scenario here
  }
})(resourceGR);

Output:


  "125d500b535973005e0addeeff8c12a2"

SCIM2ClientUtil - getProviderIdByResourceId(String provider, String resourceName, String resourceId)

Returns the unique identifier of a specified resource from a specified external provider system for a unique resource ID in a ServiceNow instance.

This API is useful when mapping ServiceNow fields to SCIM fields where the resource identifier in the external provider system is needed. Before calling this method, a unique field must be defined for the resource in the system attribute map, located in the SCIM Provider Resource Mapping [sys_scim_provider_resource_mapping] table.

For additional information on provider resource mapping, see Create a SCIM Provider Resource Mapping.

Table 3. Parameters
Name Type Description
provider String Name of the configured SCIM service provider.

Table: In the name field of the SCIM Provider [sys_scim_provider] table.

resourceName String Name of the resource type, such as User or Group.

Table: In the resource_name field of the SCIM Provider Resource Mapping [sys_scim_provider_resource_mapping] table.

resourceId String Sys_id of the resource saved in the ServiceNow instance (the client).

Table: In the primary_table field of the SCIM Provider Resource Mapping [sys_scim_provider_resource_mapping] table.

Table 4. Returns
Type Description
String Unique resource identifier used by the external service provider.

Throws an exception if there is any problem while fetching the information.

Example

The following example shows how to obtain the resource identifier of the user with the sys_id f282abf03710200044e0bfc8bcbe5d12.

var response = sn_auth.SCIM2ClientUtil.getProviderIdByResourceId('SNOW Provider','User','f282abf03710200044e0bfc8bcbe5d12'); 
gs.info('response: ' + response);

Output:


  "005d500b536073005e0addeeff7b12f4"