---
sourceDocument: Brazil Platform security
sourceDocumentLink: https://www.servicenow.com/docs/r/platform-security

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Platform security

ft:clusterId :

    - psec

bundleId :

    - psec

workflow :

    - Platform


---

# Handling unmapped fields

# Handling unmapped fields {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Handling unmapped fields

This guide explains how ServiceNow customers can handle unmapped fields during SCIM (System for Cross-domain Identity Management) customization, particularly for attributes not part of the defaultsysuserandsysusergrouptables.
It provides methods to customize SCIM client behavior, transform incoming data, and tailor responses for better integration with external identity providers.
Show full answer Show less  

## Customizing SCIM Processing

* **Creating or Updating the SCIM Client:** Administrators can add custom scripts to the *onBefore* and *onAfter* hooks to handle unmapped fields. These scripts can override default Runtime Environment (RTE) mappings and invoke scriptable APIs to transform SCIM requests and update related tables or attributes outside the standard user/group tables.
* **Accessing SCIM Context:** The method `snauth.SCIM2Util.getScimProviderCustomizationContext()` provides the SCIM request context, including the *scimResource* object, representing the incoming or current resource depending on the operation type (POST, PUT, PATCH).
* **Example Use Case:** The provided example script demonstrates how to update user roles in the **sysuserhasrole** table and manage a custom salary attribute in a separate **uusersalary** table during the *onAfter* processing.

## Customizing SCIM Responses

* For GET API calls, response payloads can be customized by extending the **SCIMProviderCustomization** script and overriding *customizeUserResponse* and *customizeGroupResponse* methods.
* These methods receive a *context* object containing the *scimResource*, representing the user or group resource, which can be modified to include additional attributes such as roles and custom extensions like salary.
* The customization script must be specified via the property `com.snc.integration.scim2.provider.customization.script.id` to be used by the SCIM plugin.
* If no modifications are made to the resource, the customization should return `null` or clear the customization script ID to avoid unnecessary processing.
* Attributes saved during *onAfter* scripts must be reflected back into the *scimResource* in the response customization to ensure consistent data in PUT and PATCH operations and in responses to clients.

## Helper Functions for SCIM Customization

ServiceNow provides several helper functions to simplify handling custom and ServiceNow-specific schema extensions during SCIM integration:

* `getCustomExtensionUrn("User")` and `getServiceNowExtensionUrn("User")` retrieve schema URNs for custom and ServiceNow extensions, respectively.
* `getCustomExtensionNodeValue("User", context)` and `getServiceNowExtensionNodeValue("User", context)` fetch corresponding schema nodes from the response context.
* `setCustomExtensionNodeValue("User", context, value)` sets updated values for custom schema nodes in the response.

These helpers enable seamless access and modification of extended attributes within SCIM resources, supporting fields stored in non-standard tables.

## Practical Benefits for ServiceNow Customers

* Enables integration with identity providers requiring custom user attributes beyond default tables.
* Allows flexible transformation and synchronization of user and group data using scripting hooks before and after data import.
* Supports customization of SCIM API responses, ensuring external systems receive enriched and accurate identity data.
* Facilitates management of complex user-role relationships and custom attributes like salary, stored in separate tables.
* Provides extensibility with helper functions that simplify schema handling and data manipulation during SCIM operations.

Overall, this capability empowers ServiceNow customers to tailor SCIM integrations precisely to their organizational identity data requirements.  
You can handle unmapped fields in SCIM customization in different ways.

During SCIM customization, the fields that are not part of the sys_user and sys_user_group tables can be mapped by performing the following functions.

## Customize SCIM (create or update) {#handling-umapped-fields__section_j5j_y3k_jtb}

You can create or update the SCIM Client.

* The SCIM admin can add custom scripts in the onBefore and onAfter scripts for fields that are not mapped in ETL Definition or RTE.
* The SCIM admin can override RTE Mappings by adding custom scripts in the onBefore and onAfter scripts.
* You can invoke a scriptable API in the RTE onBefore or onAfter scripts to access the incoming request and perform transformations on other tables, lists, and unmapped attributes.
* You can use the sn_auth.SCIM2Util.getScimProviderCustomizationContext() method to provide the SCIM request context that contains the scimResource object. The scimResource in context represents the following in each operation:
  * POST: The SCIM resource sent in the request payload.
  * PUT: The current SCIM resource from the database, replaced with the SCIM resource sent in the request payload.
  * PATCH: The current SCIM resource from the database after performing the patch operations.
  {#handling-umapped-fields__ul_ylz_ksd_mtb}

{#handling-umapped-fields__ul_dtj_rfp_gtb}  
The following is an example of an onAfter script.

    (function onAfter(source, target, importLog) {

        var ctx = sn_auth.SCIM2Util.getScimProviderCustomizationContext();
        gs.info("scim context ee: " + JSON.stringify(ctx.scimResource));

        var roles = ctx.scimResource.roles;
        if(roles) {
            var removingRolesGR = new GlideRecord("sys_user_has_role");
            removingRolesGR.addQuery("user", target.sys_user[0].sys_id);
            removingRolesGR.query();
            removingRolesGR.deleteMultiple();

        for (var i = 0; i < roles.length; i++) {
            var addingRolesGR = new GlideRecord("sys_user_has_role");
            addingRolesGR.setValue("user", target.sys_user[0].sys_id);
            addingRolesGR.setValue("role", roles[i].value);
            addingRolesGR.setValue("state", "active");
            addingRolesGR.insert();
            }
            }
            var customUserExtn = new global.SCIMProviderCustomization().getCustomExtensionUrn('User');
            var salary = ctx.scimResource[customUserExtn].salary;
            if (salary) {
                var gr = new GlideRecord("u_user_salary");
                gr.addQuery("user", target.sys_user[0].sys_id);
                gr.query();
                if (gr.next()) {
                    gr.setValue("salary", salary);
                    gs.info("scim update: " + gr.update());
                } else {
                gr.setValue("salary", salary);
                gr.setValue("user", target.sys_user[0].sys_id);
                gr.insert();
                }
               }

    })(source, target, importLog);

## Customize SCIM response {#handling-umapped-fields__section_p1f_nhp_gtb}

For the GET API calls, any response back to the SCIM client can be customized using
the script by extending the SCIMProviderCustomization
script.

While extending the script, the author can override the
customizeUserResponse and
customizeGroupResponse methods to modify the responses for
User and Group resources.

The com.snc.integration.scim2.provider.customization.script.id
property enables the SCIM plugin to use the script that should be used for response
customization.  
The following is an example of extending the base script.

    var SCIMCustomizationScript = Class.create();
    SCIMCustomizationScript.prototype = Object.extendsObject(SCIMProviderCustomization, {
        initialize: function() {
            SCIMProviderCustomization.prototype.initialize.call(this);
        },
        customizeUserResponse: function(context) {
            try {
                var rolesGR = new GlideRecord("sys_user_has_role");
                rolesGR.addQuery("user", context.scimResource.id);
                rolesGR.query();
                var i = 0;
                context.scimResource.roles = [];
                while (rolesGR.next()) {
                    context.scimResource.roles[i] = {
                        display: rolesGR.getElement('role.name').getValue(),
                        value: rolesGR.getElement('role.sys_id').getValue()
                    };
                    i++;
                }
                var userGR = new GlideRecord("u_user_salary");
                userGR.addQuery("user", context.scimResource.id);
                userGR.query();
                if (userGR.next()) {
                    var salary = userGR.getValue("salary");
                    if (salary) {
                        var customExtensionValue = SCIMProviderCustomization.prototype.getCustomExtensionNodeValue.call(this, "User", context);
                        customExtensionValue.salary = salary;
                        SCIMProviderCustomization.prototype.setCustomExtensionNodeValue.call(this, "User", context, customExtensionValue);
                    }
                }
            } catch (ex) {
                gs.error("err: " + ex);
            }
            return context;
        },
        customizeGroupResponse: function(context) {
            return context;
        },
        type: 'SCIMCustomizationScript'
    });

Note:  
* The parameter that the customizeUserResponse and customizeGroupResponse methods contain is a context object with one attribute called scimResource. This attribute has all the attributes of a user or group resource object.
* A customized script include can only be created and viewed by the admin.
* If a user or group resource is modified, then you must return the context back.
* If there are no modifications to any attribute in the resource object, then set the com.snc.integration.scim2.provider.customization.script.id to empty or return as null.
* If certain attributes are persisted through the onAfter script, they must be populated with database values in the scimResource object inside the customized script. This action is required so that the system can do the following:
  * To get the correct scimResource object in onAfter scripts during the PUT and PATCH operation.
  * To include the attributes that persisted through the onAfter script in the response back to the client.
  {#handling-umapped-fields__ul_dcw_ph5_mtb}
{#handling-umapped-fields__ul_flt_zhp_gtb}

## Helper functions {#handling-umapped-fields__section_ss3_s3p_gtb}

The following are some of the helper functions for SCIM customization. These
functions enable you to fetch or set different types of information.
{#handling-umapped-fields__table_stg_qck_mtb__entry__2}

| Function | Purpose |
|-|-|
| SCIMProviderCustomization.prototype.getCustomExtensionUrn.call(this, "User"); | Fetch the value of custom extension schema. |
| SCIMProviderCustomization.prototype.getServiceNowExtensionUrn.call(this, "User"); | Fetch the value of the ServiceNow extension schema. |
| SCIMProviderCustomization.prototype.getCustomExtensionNodeValue.call(this, "User", context); | Fetch the custom schema node from the response. |
| SCIMProviderCustomization.prototype.getServiceNowExtensionNodeValue.call(this, "User", context); | Fetch the ServiceNow schema node from the response |
| SCIMProviderCustomization.prototype.setCustomExtensionNodeValue.call(this, "User", context, customExtensionValue); | Set the custom schema node in the response. |
[Table 1. Helper functions]

{#handling-umapped-fields__table_stg_qck_mtb}  
The following is an example of using the helper function:

    var customExtensionUrn = 
    SCIMProviderCustomization.prototype.getCustomExtensionUrn.call(this, "User"); 
    var customExtensionValue = 
    SCIMProviderCustomization.prototype.getCustomExtensionNodeValue.call(this, "User", context); 
    customExtensionValue.age = "18";
    SCIMProviderCustomization.prototype.setCustomExtensionNodeValue call(this, "User", context, customExtensionValue); 

Note:  
RTE supports setting data in tables other than the sys_user and sys_user_group tables.

