Looking for Recommendation on deleting CI Relationship
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 12:26 AM - edited 04-17-2024 12:30 AM
Hello Experts.
I am looking for recommendations, on deleting relationship when it there is a duplicate.
Use case:
Created a onComplete script in a transform map to delete any duplicate relations in the relationship table.
The creation of type for business Application relationship as child with type Consumes::Consumed by and Business Application as Parent is working through an Onafter script.
I have created a script for deleting the relations, looking for some inputs. it is required urgently.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var delCMDBRel = new GlideRecord('cmdb_rel_ci');
delCMDBRel.addQuery('child', target.sys_id);
delCMDBRel.addQuery('type', '41008aa6ef32010098d5925495c0fb94');
delCMDBRel.query();
if (delCMDBRel.getRowCount() > 0) {
gs.addInfoMessage('CI relationships for ' + current.name + ' removed as it is no longer operational.');
}
while (ciRel.next()) {
ciRel.deleteRecord();
}
})(source, map, log, target);
0 REPLIES 0