File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Server-Side Components/Scheduled Jobs/Delete Retired CI Rel Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments