- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2014 07:22 AM
Hi,
How can a record in CI Relationships(cmdb_rel_ci) table can be queried to get the root CI to which all these sub CI's are related to. When I mean sub CI that can be at any level, i.e it can be a direct child to the root CI or nested child CI at 3rd or 4th level. No matter at any level or stage the CI is related to the parent CI I need the list of all the parent CI's till the root CI.
For more clear explanation refer to the screen shot below
Please share your Ideas....!
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2015 07:10 AM
Hello Mathan,
I made the below changes in one of the function definitions on the script include (CiUtils2) defined by Mark Stanger(above link)
getCIXML: function(id) {
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('child', id);
gr.query();
gr.next();
var str = '';
//str += '<CI>';
// str += '<sys_id>'+gr.child.sys_id+'</sys_id>';
str += gr.child.name+'--';
//str += '<name>'+gr.child.name+'--'+'</name>';
//str += '<relType> SELF<br></relType>';
ret = this._recurs(id);
if(ret){
// str += '<children>';
str += ret;
// str += '</children>';
}
//str += '</CI>';
return str;
},
Then created a business rule to call the above function
var ciu = new CIUtils2();
var myXML = ciu.getCIXML(current.cmdb_ci);
var a=myXML.split("--");
for (var i=0; i<a.length; i++)
{
gs.addInfoMessage(a[i]);
}
This BR displays all the related CI's of that in the cmdb_ci field...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2014 09:42 AM
Thanks Abilash.I am going to filter only business service at the moment, so not an issue for now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2015 11:03 AM
Hi Abilash,
Could you please let me know the steps used to get the directly and in directly related services to a CI, we have custom field (list) on the Incident form where we can add multiple CI's and in return we need to return all the directly and in directly related services to a CI on a custom field (list) called 'affected services'.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2015 07:10 AM
Hello Mathan,
I made the below changes in one of the function definitions on the script include (CiUtils2) defined by Mark Stanger(above link)
getCIXML: function(id) {
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('child', id);
gr.query();
gr.next();
var str = '';
//str += '<CI>';
// str += '<sys_id>'+gr.child.sys_id+'</sys_id>';
str += gr.child.name+'--';
//str += '<name>'+gr.child.name+'--'+'</name>';
//str += '<relType> SELF<br></relType>';
ret = this._recurs(id);
if(ret){
// str += '<children>';
str += ret;
// str += '</children>';
}
//str += '</CI>';
return str;
},
Then created a business rule to call the above function
var ciu = new CIUtils2();
var myXML = ciu.getCIXML(current.cmdb_ci);
var a=myXML.split("--");
for (var i=0; i<a.length; i++)
{
gs.addInfoMessage(a[i]);
}
This BR displays all the related CI's of that in the cmdb_ci field...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 05:53 AM
Hi Abhilash,
Thanks for the response, we are looking to implement something similar to what I have posted in my post on July28'2015.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 05:52 AM
Hi,
Please let me know if anyone has come across the below requirement if not please provide your suggestions. We have created 4 new tables (MNS, CPE, PE, PE Interface)that extends from CMDB.
- MNS extends from Business Service.
- CPE extends from Configuration Item.
- PE extends from Configuration Item
- PE Interface extends from Configuration Item
Also relationship has been established between these tables as below, such that MNS is the parent in the relationship
- MNS Contains CPE (MNS parent, CPE child)
- MNS contains PE Interface (MNS parent, PE Interface child)
- PE Contains PE Interface (PE parent, PE Interface child)
On the Incident table , we have added 2 list's field (Affected device CI , Affected Business Service CI) and written on Change client script such that , when you add a record from PE, CPE, PE Interface table on the 'Affected Device CI' table then the 'Affected Business Service CI' field gets auto populated with the values based on the relationship defined above.
Ex: Let's assume a record 'CPE001' from CPE table has been related with a record 'MNS001' from MSN table and if you add CPE001 on the 'Affected Device CI' field on the incident form then the 'Affected Business Service CI' field gets auto populated with MNS001.
Since PE doesn't have the direct relationship with MNS, it will look for related PE Interface (as this is the only relationship with PE has)and from PE Interface it will look for related MNS and it will be returned. Here to accomplish the requirement we have hardcoded the level and the end table from where the result should be returned.
EX: PE002 related with PEInterface002
PEInteface002 related with MNS002
So on adding PE002 , MSN002 will be returned on the 'Affected Business Service CI' field.
Please let me know if it will be possible to make the On change client script generic so that in future even if we add new tables, Affected Business Services CI values should be returned , irrespective of the level of relationship, eliminating the need to modify the script in future.
EX: Assume you add new table in future( IPE, TPE, WCE, DNS)
- IPE related with TPE (IPE can be parent or child in the relationship)
- TPE related with WCE ( WCE can be parent or child in the relationship)
- WCE related with DNS (DNS can be parent or child in the relationship)
- DNS related with MNS ( MNS can be parent or child in the relationship)
So on adding IPE001 , MNS 002 should be returned