Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This script will identify all the retired CI and update the releationship by removing it from the CIs
This is will query the cmdb_ci_rel table and fetch all ci with status as install status == 7 and parent install status == 7

As result it will delete all CI relationship and update the delete entry by querying custom table u_deleteret_app
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//get all relationship records where retired CI is Parent
var gr = new GlideRecord('cmdb_rel_ci');
gr.addEncodedQuery("child.install_status=7^ORparent.install_status=7");
gr.query();

//For each record with a retired CI
while (gr.next()) {
var par = gr.parent;
var child = gr.child;
var tp = gr.type;
gr.deleteRecord();

var gr1 = new GlideRecord('u_delete_retired_relationships');
gr1.initialize();
gr1.u_child = child;
gr1.u_parent = par;
gr1.u_type = tp;
gr1.insert();
}
Loading