Help Script parent from CI Relationships

Fidel Fernandez
Tera Expert

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:

 

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;
        }  },

3 REPLIES 3

Mark Manders
Mega Patron

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

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.

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