OnBefore Transform Scripts Error 'Create OR update CI failed'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 04:31 AM
Hello Experts,
I have a quick question. While running a transform map through a data source, I have come across the following errors
1. Row transform ignored by onBefore script - Which may be one of the expected behavior due to CMDBTransformUtil which is used as a onBefore script.
2. CreateorUpdate CI failed - no Row number
What could be the possible reasons and how it can be rectified.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var cmdbUtil = new CMDBTransformUtil();
cmdbUtil.identifyAndReconcileEnhanced(source, map, log);
cmdbUtil.setDataSource('ImportSet');
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 05:07 AM
For the first one: your script is literally saying 'set ignore to true'. If this should only be conditionally, you should add those conditions.
The second one probably is due to missing (mandatory) data, but with no row number, it will be difficult to pinpoint to the cause. Are you sure all of them have the mandatory information to be transformed?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 06:16 AM
Thank you Mark, I was able to write a script that will prevent any duplicate data and it is updating the information as it should. Do you have some examples of such conditions ?
The second one got resolved as it started populating data etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 07:04 AM
Why you are using script? Use IHETL if you are loading data in CMDB. It will call IRE and make sure no duplicates are getting inserted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 01:00 AM
Thank you so much Pratiksha for your response. I guess it is a bit late that I am joining most of the deployment is gone. I still have that question which says.
1. If I put it as Ignore = true when transforming for the following table 'cmdb_ci_lb_bigip' cmdbutils API , it just ignores the record creation and gives me an matching attributes error but we have the attributes defined at the higher table class which is hardware.
2. In order to counter it. there is a script defined with this it is working as expected, again the classification is based on category at the target table, but still want to use cmdbutils. I am bit confused why running a new load is ignoring the data...whereas when I set it to false...it is updating the information..there is an IRE defined, at the hardware level for correlation id & Serial number.
(function runTransformScript(source, map, log, target , isUpdate) {
// Add your code here
var existingRecord = new GlideRecord('cmdb_ci_lb_bigip');
existingRecord.addQuery('u_id', source.u_id);
existingRecord.query();
if (existingRecord.next()) {
log.info('Duplicate record found. Updating existing record with correlation_ID: ' + source.u_id);
} else {
target.correlation_id = source.u_id;
target.insert();
log.info('New record inserted with correlationId: ' + source.u_id);
}
})(source, target, map, log, action === 'update');