Serial Number insertion into cmdb_serial_number table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 05:51 PM
How to setup IRE rule for cmdb_serial_number?
Currently I am inserting records into cmdb_serial_number table, but instead of updating serial_number for the existing cmdb_ci (configuration item), it’s creating new record with the same cmdb_ci (configuration item). serial_number is unique value but not cmdb_ci (configuration item) in cmdb_serial_number. Seems identification rule not applicable for cmdb_serial_number because it doesn’t come under cmdb_ci. Anyone help me to resolve this? I also created a business rule to mitigate this new inserts and update existing, it is also not working. Instead of updating the record, it’s creating a new record with empty cmdb_ci.
BR code.
(function executeBefore(current, previous /*null when async*/) {
// Check if the cmdb_ci already exists in the cmdb_serial_number table
var existingRecord = new GlideRecord('cmdb_serial_number');
existingRecord.addQuery('cmdb_ci', current.cmdb_ci);
//gs.info(current.serial_number + " Current ");
existingRecord.query();
//gs.info(current.cmdb_ci + " || "+ existingRecord.cmdb_ci );
if (existingRecord.hasNext()) {
// If a record with the same cmdb_ci exists, update its serial_number
//gs.info(current.serial_number);
existingRecord.serial_number = current.serial_number;
existingRecord.update();
// Abort the current insert operation
//gs.addErrorMessage("A serial number for this cmdb_ci already exists. Serial number updated.");
current.setAbortAction(true);
return false;
}
return true;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:57 PM
@vishal_flexera Were you able to figure this out? We are expericinging the similar issue.