Notifications

20 views

Symptoms


The error below may occur when calling the Identification Engine using Import set transformation.
Ref.: https://docs.servicenow.com/bundle/london-application-development/page/app-store/dev_portal/API_reference/CMDBTransformUtil/concept/c_CMDBTransformUtilAPI.html

"Reference value field name [Name of the reference value field ] is not an identifier for the CMDB table <Table Name>[table where we are pointing to] which is the parent for reference field <Field> [Reference Feild name in the Source of the import set ]. Skipping this record"

 

Cause


An example scenario is when creating a new field on the [cmdb_ci_computer_room] table.

The error triggers when deactivating the identifier entry on the CI hardware, which is inherited by the CI computer, for the criterion attribute. The system is then not able to identify the table records using that criterion value. When enabling the identifier entry, the system is able to identify the referenced record based on the criterion attribute.

Ref. documentation on transform utilities:
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_CMDBTransformUtil-identifyAndReconcile_Object_Object_Object

When disable the transform script, this does not go through IRE, so the error is not generated. In that case, what to do with the reference field is based on how the field mapping is configured.
Ref.: https://docs.servicenow.com/bundle/london-platform-administration/page/script/server-scripting/task/t_CreatingAFieldMap.html

Resolution


Use a script to find the referenced CI and set it to the reference field. This is possible using an onAfter script of the transform map, following the steps below:

  1. Do not map the reference field in your transform map so that CMDBTransformUtil will not throw an error saying that the reference field is not an identifier.

  2. In the onBefore script that calls CMDBTransformUtil to make the following change so that the sys_id of the record inserted/updated by IRE is captured:

    target.sys_id = cmdbUtil.getOutputRecordSysId(); // add this line in the else block of if(cmdbUtil.hasError()) condition
    log.info('IE Output Payload: ' + cmdbUtil.getOutputPayload()); // this line is already there

  3. Create a new 'onAfter' transform script with the code listed below. It should run after the CMDBTransformUtil has identified the record to insert/update.
    This script should find the referenced CI and set it to the reference field.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) { 

//find the referenced CI based on the attributes we know
//In this case we have the name of the referenced CI in the source
//If the source has more fields on the referenced CI we can add them to the query so that
//we can get the matching CI
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('name', source.getValue('u_test_computer'));
gr.query();
if (gr.next()) {
var referencedSysId = gr.getValue('sys_id');
var targetSysId = target.getValue('sys_id');
//update the target with the reference
var gr2 = new GlideRecord(target.getTableName());
if (gr2.get(targetSysId)) {
gr2.setValue('u_test_computer', referencedSysId);
gr2.update();
}
}
})(source, map, log, target);

Article Information

Last Updated:2019-05-21 11:58:29
Published:2019-05-14