List of CI.s  Upstream and downstream

pramn
Kilo Sage

Hi Mates, 

one of my clients needs for reporting purpose List of CI.s  Upstream and downstream data ..

Is there any possibility to get those data .

or need to write any scripting .

Need your help !

 

Thanks 

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

Hi @pramn 

 

https://www.servicenow.com/community/itsm-forum/ability-to-export-all-upstream-and-downstream-ci-s-f...

 

https://www.servicenow.com/community/itom-forum/how-to-get-data-cmdb-ci-upstream-and-downstream-data...

 

https://www.servicenow.com/community/platform-analytics-forum/hi-all-is-there-a-way-to-report-on-the...

 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Its_Sagnic
Mega Guru

Hi @pramn ,

In ServiceNow, all CI relationships are stored in the CI Relationship table (cmdb_rel_ci).
Whenever a relationship is created between two CIs, the platform automatically inserts a record into this table with:

  • a Parent CI
  • a Child CI
  • and the Relationship Type (e.g., Depends on, Contains, etc.)

Creating a Report

If your requirement is to report on upstream/downstream CIs, you can build a report directly on the cmdb_rel_ci table.
To get all CIs related to a specific parent CI, set:

  • Table: cmdb_rel_ci
  • Group By: Parent
  • Apply filters as needed.

This will give you a list of all child CIs related to each parent CI.

Retrieving Child CIs via Script

If you want to programmatically list the child CIs and print their names in the logs, you can use the following script:

var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent','14bca7efdb0c10104779141b13961998');//the sys_id of parent CI .
var count = 0;
gr.query();
while(gr.next()){
	count++;
	gs.print ('The Child name ' +gr.child.name+' is '+count+' th child');
}

 

This script loops through all relationship records where the specified CI is the parent, counts them, and prints each child CI’s name and order.

If this solution helps, please mark it as Helpful and Accept the Solution to close the thread.

Regards,

Sagnic