Palash_Sarkar
ServiceNow Employee
ServiceNow Employee

Problem

After a ServiceNow family release upgrade or patch update, certain field labels in the target table (e.g., cmdb_ci_computer) may be changed due to localization improvements (especially for non-English locales such as Japanese). This results in:

  • Users downloading a data import template using updated field labels.

  • When importing data using this new template, the import set table (e.g., imp_computer) may create new fields instead of mapping to existing ones.

  • As a result, data fails to transform to the target table because the Transform Map no longer aligns with the import set labels.

Scenario

For example:

  1. Before the upgrade, a field had the Japanese label "所在地".

  2. After the upgrade, the label changes to "ロケーション".

  3. A new column is created in the import set when uploading data with the "ロケーション" column, leading to transform map failure.

Workaround Solution

To solve this issue, you can identify mismatched labels between the import set source table and the target table using a custom UI Action and Script Include.

 

Note: If the transform map target table record empty then this script can't compare with the target table lable. Result of comper will be null.

 

Approach

  1. Compare labels for each field defined in the Transform Map:

    • Source Field (Import Set Table)

    • Target Field (Target Table)

    • Check if their localized labels (e.g., in Japanese) differ.

  2. Log mismatches for further investigation.

  3. Use the result to update the import set template or transform map accordingly.

Implementation

1. Script Include

CompareTransformMapsAjax

Palash_Sarkar_0-1750235516573.png

 

var CompareTransformMapsAjax = Class.create();
CompareTransformMapsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    processCheckedRecords: function() {
        // comma-separated sys_ids
        var ids = this.getParameter('sysparm_ids');
        if (!ids) return "No IDs provided.";

        var result = [];
        var idArray = ids.split(',');

        for (var i = 0; i < idArray.length; i++) {
            var tm = new GlideRecord('sys_transform_map');
            if (tm.get(idArray[i])) {
                var tmName = tm.name;
                result.push('▶ Transform map name: ' + tmName);

                var entry = new GlideRecord('sys_transform_entry');
                entry.addQuery('map', tm.sys_id);
                entry.query();

                while (entry.next()) {
                    // Retrive target table from the table record.
					var srcTblName = entry.source_table;
                    var trgTblName = this.getTargetTableName(entry.target_table, entry.target_field);

                    var sourceLabel = this.getLabelInfo(srcTblName, entry.source_field);
                    var targetLabel = this.getLabelInfo(trgTblName, entry.target_field);

                    if (sourceLabel !== targetLabel) {
                        result.push('Mismatch detected - Source Label: ' + sourceLabel + ' | Target Label: ' + targetLabel);
                    }
                }
            }
        }

        gs.addInfoMessage(result.join('<br/>'));
        return "Done!";
    },

    getLabelInfo: function(tableName, elementName) {
        var sysDoc = new GlideRecord('sys_documentation');
        var userLang = gs.getSession().getLanguage();

        sysDoc.addQuery('name', tableName);
        sysDoc.addQuery('element', elementName);
        sysDoc.addQuery('language', userLang);
        sysDoc.query();

        if (sysDoc.next()) {
            return sysDoc.label.toString();
        }
        return null;
    },

    getTargetTableName: function(TableName, FieldName) {
        // Get a single table record
        var grTrg = new GlideRecord(TableName);
        grTrg.query();
        grTrg.next();

        //Retrieves a Java ArrayList of fields in the current record.
        var fields = grTrg.getFields();

        for (var i = 0; i < fields.size(); i++) {
            var field = fields.get(i);
            var tblFieldName = field.getName(); // Name of the field

            if (FieldName == tblFieldName) {
                var tableName = field.getTableName(); // Table of the field
                return tableName;
            }
        }
        return null;
    }
});

2. UI Action (List Button on sys_transform_map)

UI Action.JPG

 

function onClick() {
    var selected = g_list.getChecked(); // get selected records
    if (!selected) {
        alert("Please select at least one record.");
        return;
    }

    // GlideAjax call to server-side script include
    var ga = new GlideAjax('CompareTransformMapsAjax');
    ga.addParam('sysparm_name', 'processCheckedRecords');
    ga.addParam('sysparm_ids', selected);
    ga.getXMLAnswer(function(response) {
        alert(response);
    });
}

3. Select one or more transform maps from the list and click the UI Action (List Button on sys_transform_map

Result.JPG

 

Result

By running this UI Action, users can:

  • Instantly check for label mismatches after upgrades.

  • Prevent incorrect field creation in import sets.

  • Ensure smooth transformation of imported data without customization.

Note: If the Transform Map's target table has no records, the script will be unable to compare field labels. As a result, the comparison will return null.

 

Troubleshooting

This Script Include is created in the global scope, and when you select a Transform Map from a different scope, the script will throw a cross-scope access error. This means you need to explicitly allow the script to run across different application scopes. The error will appear as shown in the image below.

Palash_Sarkar_1-1750236268043.png

 

To resolve this issue:

Grant permission for the Script Include to run in a cross-scope context. In the navigation filter, search for "Application Restricted Caller Access Privileges".

Palash_Sarkar_3-1750236386004.png

 

Filter by Status = Requested. You will see your Script Include listed in the Source field. Open the record and change the Status from Requested to Allowed

Palash_Sarkar_4-1750236822604.png

 


Recommendation

After every ServiceNow upgrade or patch:

  • Run this label check against your key transform maps.

  • Update templates or transform maps as needed.

  • Educate import users to always use the latest, verified templates.

Version history
Last update:
‎06-18-2025 02:00 AM
Updated by:
Contributors