Transform Map and Target Table

endoflineone
Kilo Explorer

The wiki says that the target can be dynamically set when processing import set data into the CMDB tables.

I have successfully done so when the sys_class_name is a sub-class of the of the Target Table selected from the drop, e.g. cmdb_ci is the Target Table and target.sys_class_name = 'cmdb_ci_spkg' is scripted.

I have not been so successful when the target tables do not share a common super-class.

I have an import/integration data that has People and Group relationships to Configuration Items. In the transform map script I can examine a flag and know if the target.sys_class_name = 'cmdb_rel_person' for People or target.sys_class_name = 'cmdb_rel_group' for Group. From the system log I can see that I am picking the correct CI and the Person/Group and set the appropriate relationship type.

I see sys_class_name is not available to all tables; Only base tables like Task, SLA, Configuration Item, etc.

Is there another way to set Target Table in Transform Map script?

2 REPLIES 2

DavidLoo
Kilo Contributor

since the script is free form, you could create data into any table by simply using the standard GlideRecord API, and selectively copy values over from target

eg.

var newGR = new GlideRecord("any_table");
newGR.initialize();
newGR.filed_one = target.filed_one;
newGR.insert();

and finaly if you want to ignore the current target record creation, just set ignore = true;


Thank you. That is exaclty what I ended up doing.

I also see that this will need to be the direction to handle assignments to sub-class elements that are unique to the sub-class. So trying to pick the sub-class as the target table in the Field Map causes error/conflict with the Transform's target table. Which shows me that Field Maps are only applicable to the common elements shared by all sub-classes.