How to create a report to show CIs with no relationship?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 12:57 PM
Hello everyone,
I need to create a report to show all CIs without a relationship to anything.
Any idea what the query should look like?
Has anyone ever done anything like that?
Thanks,
- Labels:
-
Data Foundations
-
Data Health Tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 07:39 AM
Hi Akif,
Sorry the late response!
Here is what I did (sorry, I'm very new in scripting).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 01:03 PM
Your script include should be something like this
function ciWithNoRelationships(){
var cisWithNoRelationship = [];
var ciGR = new GlideRecord("cmdb_ci");
//ciGR.addEncodedQuery("sys_class_name!=cmdb_ci_endpoint_ajp^ORsys_class_name!=cmdb_ci_ad_controller");//Use this to exclude certain CI Classes
ciGR.query();
while(ciGR.next()){
var relGR = new GlideRecord("cmdb_rel_ci");
relGR.addEncodedQuery("parent="+ciGR.sys_id+"^ORchild="+ciGR.sys_id);
relGR.query();
if(relGR.getRowCount() == 0){
cisWithNoRelationship.push(ciGR.sys_id.toString());
}
}
return cisWithNoRelationship;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:56 AM
Hi Luiz,
If you'd like to accomplish this without scripting or creating a single new report, you might want to try Data Content Manager, a ServiceNow certified Built on Now app available in the ServiceNow Store.
If you just want to see how it work, you can book a 30-minute demo where I can demonstrate this exact use case.
Cheers,
--Mikko

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 01:28 PM
CMDB Query Builder allows this logic. From here you can create and schedule a report that will then become a data source. You may want to break it down to specific use cases such as Business Applications with no relationships to Application Services. Computers for example (personal) may not have a CI relationship.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 10:07 AM
Hi Eric,
Looks like when migrated to this new community it lost the images.