createOrUpdateCI failed import set error

Mark Wood
Tera Contributor

Hello Experts,

I am trying to import ci data but I am getting a createOrUpdateCI failed error. on the transform run script, I have written below code:

 

(function transformRow(source, target, map, log, isUpdate) {

	var Tram = (parseInt(source.u_total_physical_memory)* 1024);
	gs.log("Ram"+Tram);
if (source.u_class_name == 'Computer') {
target.ram.setValue(Tram);
target.sys_class_name = 'cmdb_ci_computer';
}
if (source.u_class_name == 'server') {
target.ram.setValue(Tram);
target.sys_class_name = 'cmdb_ci_server';
}
if (source.u_class_name == 'Unix Server') {
target.ram.setValue(Tram);
target.sys_class_name = 'cmdb_ci_unix_server';
}

})(source, target, map, log, action==="update");

 

 and I have used below event script to call IRE.

 

(function runTransformScript(source, map, log, target) {
// Call CMDB API to do Identification and Reconciliation of current row
var cmdbUtil = new CMDBTransformUtil();
cmdbUtil.identifyAndReconcile(source, map, log);
ignore = true;

if (cmdbUtil.hasError()) {
        var errorMessage = cmdbUtil.getError();
        log.error(errorMessage);
} else {
        log.info('IE Output Payload: ' + cmdbUtil.getOutputPayload());
        log.info('Imported CI: ' + cmdbUtil.getOutputRecordSysId());
}

})(source, map, log, target);

 

 please guide me why I am getting this error.Thank you.

3 REPLIES 3

Why are these nonsense replies from nowgpt.ai and nowkb.com  only increasing?! The level on the community gets horrible this way.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

akkkiii95
Tera Contributor

Kelvin
Tera Contributor
What worked for me was to log the payload and put it in the Identification Simulation.
 
In script include CMDBTransformUtil log the inputPayload - I used the identifyAndReconcileEnhanced function in my transformmap, this might be a bit different for you:
 
identifyAndReconcileEnhanced: function(source, map, log) {
if(!this.isPayloadProvided) {
this.inputPayload = this.buildInputPayload(source, map, log);
gs.log('this.inputPayload = ' + JSON.stringify(this.inputPayload));
}
this.identifyAndReconcileFromPayloadEnhanced(this.inputPayload, map, log);
},
In  the simulator select 'Start with Existing Payload'. As datasource select ImportSet (might have to type it), copy/past the payload and run the simulation.
 
In my case it turned out I was missing some mandatory fields in the payload which I was not aware of as the fields on our cmdb table were readonly and could not create new records directly.