How can I update the model & model category fields within the hardware table during an asset import?

mdjoseph12
Giga Contributor

Is it possible, perhaps through field map scripts, to update the model & model category reference field during an import to the hardware table? 

 

 

1 ACCEPTED SOLUTION

Harshinya1
Mega Guru

You will have to create two transform maps

1. First map to import hardware models - create models and tied model categories to the model. Make sure to ignore for any invalid model categories. This should be done to import any models that are not in ServieNow.

2. Second map to import assets and tie the first imported model and associated model categories to the asset

 

 

In the field mapping you can try below code. you can try this for both model and model categories 

var modelname='value from import set';
var model = new GlideRecord('cmdb_hardware_product_model');
model.addQuery('display_name', modelname);
model.query();
if(model.next()){

target.model = model.sys_id.toString();
}

Hope this helps

View solution in original post

2 REPLIES 2

Harshinya1
Mega Guru

You will have to create two transform maps

1. First map to import hardware models - create models and tied model categories to the model. Make sure to ignore for any invalid model categories. This should be done to import any models that are not in ServieNow.

2. Second map to import assets and tie the first imported model and associated model categories to the asset

 

 

In the field mapping you can try below code. you can try this for both model and model categories 

var modelname='value from import set';
var model = new GlideRecord('cmdb_hardware_product_model');
model.addQuery('display_name', modelname);
model.query();
if(model.next()){

target.model = model.sys_id.toString();
}

Hope this helps

rbs77
Tera Contributor

Recently I was able to import Models & fields except the Category field through the Excel Import.