CMDB: Consider Script in Transform Map while using "Identification and Reconciliation framework"

MarcB1
Tera Guru

Hi

I added the code from https://developer.servicenow.com/app.do#!/api_doc?v=geneva&id=r_CMDBTransformUtil-CMDBTransformUtil   to a "onBefore" Transform Map Script.

It workes very well, but unfortunately it ignores the Transform Map Script itself (the onBefore works fine)

In the Script I usually enrich various CI attributes based on fields I read from SCCM. e.g. set Company based on the Domain Name.

Any advice?

BTW: very good examples https://community.servicenow.com/docs/DOC-6808

SCCM 2012 Computer Identity _ IT Service Management - Google Chrome 2017-05-26 19.57.43.png

onBefore _ IT Service Management - Google Chrome 2017-05-26 19.59.51.png

16 REPLIES 16

My use pattern for CMDB Transform Maps is to target multiple classes of devices by using logic to set target.sys_class_name as needed. for instance cmdb_ci_hardware is what I set the main table for the Map to, but some devices will go into cmdb_ci_computer, cmdb_ci_linux_server or whatever.



It seems that the CMDBTransformUtil.identifyAndReconcile(source, map, log) doesn't include the target record, since it performs inserts without the target object. I've been having limited success in grabbing the updated / inserted record sys_id and placing it back in the source.sys_target_sys_id field, but I have not been able yet to achieve my goal of specifying a sys_class_name other than the one from the map object. I have even tried to do this...



var table_map = {};


table_map.Desktop       = 'cmdb_ci_computer';


table_map.Workstation = 'cmdb_ci_computer';


table_map.Laptop           = 'cmdb_ci_computer';


table_map.Server           = 'cmdb_ci_hardware';


table_map.Tablet           = 'cmdb_ci_comm';



// source.u_hardware_class_sn contains one of the values above for mapping


var target_class = table_map[source.u_hardware_class_sn];


map.target_table = target_class;



var cmdbUtil = new CMDBTransformUtil();


cmdbUtil.identifyAndReconcile(source, map, log);


ignore = true;



But this doesn't work either. Are we limited to a single target class per Transform Map when using the CMDBTransformUtil?


Paul Coste2
Giga Expert

If you use the CMDBTransformUtil API, you should note that due to the need to ignore the default behavior of the field mappings, you will no longer be able to view the status of the transform via the transform history.  All rows will show as ignored, even if the records were updated.  This seems to be a design issue; the API should have been implemented in a way to support updates to the transform history.  Not sure if others have reported this, but this is a problem for anyone looking to implement CMDBTransformUtil API to use on their existing scheduled imports.  In addition, we found that the updated date on the record in some cases seems to be updated even when no other fields were changed.