Import multiple tables at the same time and create relationship among them

ritsu
Tera Contributor

I need to import data to Computer (cmdb_ci_computer) and DIsk (cmdb_ci_disk) by transform maps at the same time, and I will excuse the transform map by order. 

but I don't know how to set the pass the Computer sys_id to DIsk because the  Computer would not created when DIsk is importing.

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Ritsu,

Not sure about your requirement but I believe you can create 2 transform map having the same source table for example imp_computer import set table.

if your file is something like below:

find_real_file.png

in this there are 2 computer record and each computer has 8 disk record. So 2 computer record should be created and 8 disk record (4 disk for each computer with computer reference on it).

You can create a transform map for Computer table and set colease on Serial Number field. 

You can create a transform map for Disk table and set the colease on fields like Name and Computer field (you can change this as per your need). You have to run the computer transform map 1st and then Disk transform map. On disk transform map you can use [script] type source field to get the sys_id of computer record as shown below:

answer = (function transformEntry(source) {

	var computerRecord = new GlideRecord("cmdb_ci_computer");
	if (computerRecord.get("serial_number", source.u_serial_number)) {
		return computerRecord.getUniqueValue();
	}

})(source);

Field mapping for Disk table transform map:

find_real_file.png

You will see 2 computer record inserted (other 6 got ignored) and 8 Disk record as shown below:

find_real_file.png

Please mark this as helpful/correct, if it answer your question.

Thanks

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

your 1st transform map should then be for computer and then disk

When your 2nd transform map runs it will try to find the computer with the name

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader