Walk through CI relation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:23 AM
Hi Everyone,
I am trying to find all the ci that have the relation to as in dependency views in a script.
Any help is appreciated.
Regards,
Yusuf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 03:55 AM
Thanks Maik,
I am aware of that approach but I thought there might be some code that guides me to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 04:01 AM
Use below code to get relationship-
function u_getmyCIRel(ci) {
var rel = '';
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', ci);
gr.addQuery('parent.sys_class_name', "=", 'cmdb_ci_appl');
gr.addQuery('child.sys_class_name', "=", "Application Environment");
gr.query();
gs.log(gr.getRowCount());
while (gr.next()) {
rel += "," + gr.child;
}
gs.log('sys_idIN' + rel.substring(1));
return 'sys_idIN' + rel.substring(1);
}
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 05:21 AM
This code just gives the first level how about the ci that have the connection to others?