Skip to content

Commit cc067f9

Browse files
authored
Merge pull request #2454 from d-sharmagit/deleteretiredcirel
Deleteretiredcirel
2 parents d9aafaa + 472575c commit cc067f9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This script will identify all the retired CI and update the releationship by removing it from the CIs
2+
This is will query the cmdb_ci_rel table and fetch all ci with status as install status == 7 and parent install status == 7
3+
4+
As result it will delete all CI relationship and update the delete entry by querying custom table u_deleteret_app
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//get all relationship records where retired CI is Parent
2+
var gr = new GlideRecord('cmdb_rel_ci');
3+
gr.addEncodedQuery("child.install_status=7^ORparent.install_status=7");
4+
gr.query();
5+
6+
//For each record with a retired CI
7+
while (gr.next()) {
8+
var par = gr.parent;
9+
var child = gr.child;
10+
var tp = gr.type;
11+
gr.deleteRecord();
12+
13+
var gr1 = new GlideRecord('u_delete_retired_relationships');
14+
gr1.initialize();
15+
gr1.u_child = child;
16+
gr1.u_parent = par;
17+
gr1.u_type = tp;
18+
gr1.insert();
19+
}

0 commit comments

Comments
 (0)