CI relationships multilevel downstream in a list

saksham2
Kilo Contributor

Suppose we have a CI X

Its parents are P,Q and children are Y,Z

Now Y has children C and D and Z has children E and F.

I have to get all child CI's ( Y,Z,C,D,E, F) in a single list.

I am using the code (sample)

var childlist = [] ;

var prel = new GlideRecord ('cmdb_rel_ci');

prel.addQuery('parent',current.cmdb_ci);

prel.query();

while (prel.next())

{

gs.print ("list is" +prel.parent);

childlist.push(prel.child.toString());

}

But I get only 1 level downstream Ci   (ie, CI   Y and Z ,the children for current Ci X )from this.

How do I get the 2nd level downstream Cis and the subsequent levels for X ( ie   C,D,E,F)

?

6 REPLIES 6

gyedwab
Mega Guru

Without using code, you can use Explore Analytics to query downstream CIs.



In my example, this is what my stack for the business service Bond Trading looks like:



Screenshot 2018-01-17 10.24.47.png



I created a list report with the filter "sys_id is downstream from Bond Trading":


Screenshot 2018-01-17 10.25.40.png


In the list above, you can see even CIs that are multiple levels down (like PS Apache 01/02/03 or nyc oracle rac cluster) are shown.



You can also traverse the opposite way:


Screenshot 2018-01-17 10.27.34.png



You can also group by an upstream or downstream dependency, and do a lot more refined filtering on the hierarchy.



For more information, you can watch our video on Business Service Reporting (it's not just limited to Business Services but that's a common use case).


dharanikumar
Giga Guru

Thanks for the reply but i need some code to work ongyedwab


We trying to get all the Child CIs and insert into the affected CIs related list.