CMDB: Consider Script in Transform Map while using "Identification and Reconciliation framework"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2017 11:03 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 09:59 AM
Mani,
Any thoughts on this on how to make to use of run script or other transform scripts along with the Identity and Reconciliation framework?
We tried using scripts for field mapping in Jakarta in conjunction with the CMDBTransformUtil and they still get ignored.
We really would like to make use of Identification and Reconciliation framework mechanism during import of data from external data sources, but would like to retain the earlier capability of filed mapping using scripts for manufacturer, model and other fields as below. Is there something which needs to be done to achieve this?
var mm = MakeAndModelJS.fromNames(source.u_manufacturer, source.u_model, "hardware");
target.model_id = mm.getModelNameSysID();
target.manufacturer = mm.getManufacturerSysID();
Regards,
Sandesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 01:46 PM
Looking at the CMDBTransformUtil.getTransformValues() function, it uses the transform map fields list to copy
source field values to inputPayload fields (which are json'ed as input to the backend createOrUpdateCI() function).
As you noted, it doesn't run any field scripts. I'm experimenting with the following code updates to the CMDBTransformUtil
Script Include:
// Get values that need to be transformed for given source record
getTransformValues: function(source, sourceTable) {
var values = {};
var entryGr = new GlideRecord(this.transformEntryTable);
entryGr.addQuery('source_table', sourceTable);
entryGr.query();
while(entryGr.next()){
var targetField = entryGr.getValue('target_field');
if (entryGr.use_source_script) {
var answer = null;
eval(entryGr.getValue('source_script')); /* sets answer variable */
if (answer) {
values[targetField] = answer;
}
} else {
var sourceField = entryGr.getValue('source_field');
values[targetField] = source.getValue(sourceField);
}
}
return values;
},
This seems to work great. However there is another "gotcha" between what the identification/reconciliation engine
does with reference fields (let say "Owned by" which is reference to User table) and a standard transform.
The Ident/Recon doesn't seem to resolve the target field via a reference lookup, you have to resolve it to a sys_id
yourself. The standard transform map will handle this automatically.
I don't have Jakarta yet so don't know if the CMDBTransformUtil has been updated (I'm on Istanbul).
Anyone know how to make ident/recon do the reference lookups?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2017 11:52 AM
I have had a chance to look at the Jakarta CMDBTransformUtil() script. It does do reference lookup using
resolveReferenceField API call. It won't backport to Istanbul, so don't bother. It does an arguably better job
with source_script evaluation rather than simply calling 'eval()'.
However, there is a serious bug if you have more than one transform map defined on a single import set table.
This is true of Istanbul as well. You need to insert an additional condition when you loop through the source
table fields from the sys_transform_entry table. Otherwise, the import fields from other maps will pollute your
import data structure.
var entryGr = new GlideRecord(this.transformEntryTable);
entryGr.addQuery('source_table', map.source_table);
entryGr.addQuery('map', map.sys_id); /* restrict to this map only */
entryGr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2017 08:12 AM
Hi Mark,
Prior to Jakarta release, we did not supported source script with CMDBTransformUtil, but this capability is now supported in Jakarta. Meanwhile, as a workaround prior to Jakarta release, the way to do this is to enrich your source in onBefore script just before you call CMDBTransformUtil.
Thanks,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 09:02 AM
Manish,
We tried using scripts for field mapping in Jakarta in conjunction with the CMDBTransformUtil and they still get ignored.
We really would like to make use of Identification and Reconciliation framework mechanism during import of data from external data sources, but would like to retain the earlier capability of filed mapping using scripts for manufacturer, model and other fields as below. Is there something which needs to be done to achieve this?
var mm = MakeAndModelJS.fromNames(source.u_manufacturer, source.u_model, "hardware");
target.model_id = mm.getModelNameSysID();
target.manufacturer = mm.getManufacturerSysID();
Regards,
Sandesh.