CI should not create with lifecycle status "End of life", but it should update if status is changing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 11:48 PM
I am loading the data using Robert Transform Map in CMDB, requirement is that if the Lifecycle status is "End of Life", CI record should not create. And if there is an existing CI record with different status, and if in source status is changing to "End of Life", the CI record should update. I have written the below script, it working for creation part, but not working for Update. Can anyone help?
(function onBefore(source, target, importLog) {
var lifecycleStatus = source.u_life_cycle_stage;
// If the record is new and status is "End of Life", skip creation
if (!target.isValidRecord() && lifecycleStatus == "End of Life") {
ignore = true;
return;
}
// If updating and status is "End of Life", update the field if it's different
if (target.isValidRecord() && lifecycleStatus == "End of Life") {
if (target.life_cycle_stage != lifecycleStatus) {
target.life_cycle_stage = lifecycleStatus;
} else {
ignore = true;
}
}
})(source, target, importLog);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 07:46 PM
One simple solution would be to just add an insert BR to abort CI creation if Life Cycle Status is "End of Life". For update you don't have to do anything as it will be handled automatically.