Bulk Upload CI Relationship based on Child Class and Parent Class

Ishan4
Tera Contributor

I am bulk uploading relationships to cmdb_rel_ci table using Transform Map, the source table has Child Name, Child Class, Type, Parent Name, Parent Class fields but the target has only Child, Parent and Type fields and there is no direct way to target class of child and parent.

The issue is happening when there are CIs with same but different class of cmdb, so suppose if I want CI name 'ABC' of class 'Application Service' as child but transform is itself picking up CI named 'ABC' of class 'Business Service'.

It seems targeting sys_id is not allowed to script/manually using even admin.

What should be done to solve it ? Any onBefore script can be suggested ?

1 ACCEPTED SOLUTION

suvro
Mega Sage
Mega Sage

For each mapping use script instead of field to field mapping

For Parent field

var par = new GlideRecord (source.u_parent_class);

par.get('name', source.u_parent_name);

return par.sys_id;

 

For Child field

 

var child = new GlideRecord (source.u_child_class);

child.get('name', source.u_child_name);

return child.sys_id;

View solution in original post

5 REPLIES 5

Ishan4
Tera Contributor

I asked this question and I have found one more answer which does not use script, still the one marked as correct answer to this question is liked by me more.

So what can be done is extract the sys_id of parent and child only and use that in the target field and target referenced field name, see following pics:

for accessing it first create a field map of source sys_id field to target parent field and same for child target field then click on the entry in field map list on transform map form.

find_real_file.png

Note: This option will only come if the target field is referenced field, I was searching once for it in a transform map targeting non-referenced fields. ;/ .

find_real_file.png