Help Script parent from CI Relationships
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 12:51 AM
Hi everyone,
First, let me apologize if my question is in another community forum - i need your help.
From table cmdb_rel_ci,have , it's something like this:
Parent | Type | Child |
---|---|---|
Resources | Defines resources for::Gets resources from | [DATACENTER] Principal |
Reception | Contains::Contained by | Reception Pro |
Find all the parents of the child "Application Service", some Childs are from table Application service (cmdb_ci_service_auto), check the parents one by one and you only keep the ones that sys_class_name=service_offering and finally return a query to show only those service offerings.
I don't know how to start,i really need your help.
var applicationParent = Class.create();
applicationParent.prototype = {
initialize: function() {},
getNameApplication: function() {
var grRelationship = new GlideRecord('cmdb_rel_ci');
grRelationship.addQuery('parent.sys_class_name',"=",'mdb_ci_service_auto');
grRelationship.addQuery('child.sys_class_name', "=", "Aplication Service");
grRelationship.query();
while (grRelationship.next()) {
}
return grRelationship;
} },
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 02:21 AM
You can report on the Parent and add the condition 'child.class = service_offering' if I'm understanding your question properly. If not: please let us know what you are looking for.
If my answer helped you in any way, please then mark it as helpful. If it resolved the issue, please mark it as correct.
Mark
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 07:06 AM
Hi Mark.
That's not correct.
Query to table "cmdb_rel_ci".
- Find all the parents of the child "Application Service"
- You check the parents one by one and you only keep the ones that sys_class_name=service_offering
- You return a query to show only those service offerings.
I don,t know how to star my code, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2022 11:21 PM
Still not clear what the issue is. You want all the 'applicaton services' that are a child to a 'service offering'. That means you can create a simple report on the cmdb_rel_ci table whith 'child.class = application service AND parent.class = service offering'. That gives you the results you need (as I understand your question).
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark