Tranform maps

Hari S1
Tera Contributor

Hi,

I tried to implement below requirement but unable to find the solution. can someone help me

"Suppose I have an Excel sheet where there are 10 columns of data. First five columns belong to the Hardware table and the last five columns belong to the Software table. I want to map these data into ServiceNow (Hardware & Software tables) in a single upload?

1 ACCEPTED SOLUTION

Rajesh Chopade1
Mega Sage

hi @Hari S1 

 

hi @Hari S1 

This is not directly supported by a single import set, because each import set maps to one target table at a time. But you can achieve this by a multi-step process.

 

Upload your Excel as usual via Load Data (System Import Sets > Load Data).

Choose Create new table or use a staging table.

This import set table will contain all 10 columns in one record per row.

 

Create two transform maps on that import set table:

One transform map for the Hardware table (mapping columns 1-5). In the Field Maps related list, use Auto Map Matching Fields to map the first five columns.

One transform map for the Software table (mapping columns 6-10).

 

Use Transform Scripts (onBefore or onAfter Transform) to separate data, Because each transform map is triggered per row, but you want to create two records from one row (one hardware, one software), you need some scripting:

 

Create a transform map to Hardware.

Use an onAfter transform script to create Software record as bellow.

(function transformEntry(source, target, map, log, isUpdate) {
var softwareGR = new GlideRecord('software_table_name');
softwareGR.initialize();
softwareGR.field1 = source.u_col6;
softwareGR.field2 = source.u_col7;
softwareGR.field3 = source.u_col8;
softwareGR.field4 = source.u_col9;
softwareGR.field5 = source.u_col10;
softwareGR.insert();
})(source, target, map, log, isUpdate);


I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

View solution in original post

5 REPLIES 5

Chaitanya ILCR
Kilo Patron

Hi @Hari S1 ,

if software and hardware are child of any table you can simply use sys_class_name and set the table name 

 

else

 

you can create 2 transform maps 1 for software table and 1 for hardware table with single import both will run and move the data to the respective tables

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @Chaitanya ILCR ,

 

Rajesh Chopade's solution worked for me. However, I would like to know how I can create two transform maps for a single import set table. Could you please share screenshots of the transform maps and where they should be created?

Thanks!

Hi @Hari S1 ,
keep the source table as same and change the target table

example source table is imp_user and target is table1 and table2

ChaitanyaILCR_0-1748615689453.pngChaitanyaILCR_1-1748615693805.png

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

Hristo Ivanov
Kilo Sage

as Chaitanya mentioned, you need two transform maps