If parent CI is retired, then child CI CI needs to be retired
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 09:18 AM
Hello All,
I have below requirements:
When a discovered CI is Retired all components that were discovered on the CI should automatically be retired with the CI is Retired.
Any way to develop something that will look at all CIs and if parent CI is anything other than Install Status "Installed" then the child CIs are updated to Retired or to match the status of the parent CI.
Any help will be appreciated.
Regards,
Hanumant
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 02:07 PM
Hi, if there is no other requirement\dependency then a simple 'after' BR could be all you need
trigger conditions;
current.operational_status.changes() && current.operational_status == 6 //retired.
script;
//query for child relationships
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', current.sys_id);
gr.query();
while(gr.next()) {
//for each child found look up the record and update the status
var myCI = new GlideRecord('cmdb_ci');
if(myCI.get(gr.child.sys_id)) {
myCI.operational_status = 6;
//Or you could make this child state dynamic by ommiting state 6 from the trigger conditions and referencing the current CI's status
//myCI.operational_status = current.operational_status;
myCI.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 08:17 AM
Hi Tony,
Thank you so much for help.
As of now no other requirements, but let me check if the point mentioned by
Do you suggest BR or scheduled job for this for long term.
But for now we are only asked to change statuses of the child CIs.
Regards,
Hanumant

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2022 08:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2022 04:39 AM
The above BR should run on "cmdb_ci_rel" table?
will that make child CI status to retired as expected?
Regards,
Hanumant