Report on services that don't have a business application is not working

Robert Campbell
Tera Guru

We haven't yet converted all of our business services to application services but I'm trying to see which services don't have a business application.

RobertCampbell_0-1744406220701.png

This is not working. There are some services that don't have a business application related to it but many of them do.

 

I want to see everything from the cmdb_ci_service table that doesn't have a relationship to something on the cmdb_ci_business_app table.

 

How do I create a report to show this data?

3 REPLIES 3

Maik Skoddow
Tera Patron
Tera Patron

Hi @Robert Campbell 

a "Business Application" is NOT an Application Service! Therefore, I guess you mean "Business  Application" instead, right? And you always should have the related CSDM version in front of your eyes when building the query, as in the following diagram you can see, that Business Applications are connected to Business Services via Business Capabilities.

 

MaikSkoddow_0-1744422861334.png

Maik

 

We are softly operating off CSDM 3.0. We are also still using the label business service for most of our application services cmdb_ci_service not cmdb_ci_service_business. Since we don't currently have any official business services and we aren't using technical services the only thing in that table is application services of various types. So I am trying to keep a report of which application service doesn't have a parent business application.

Hi @Robert Campbell 

with the Query Builder you can only report on existing data. If you want to find out you can leverage a script. The following script finds out all Services that are not connected to anything. Adapt it according to your needs if required:

var unconnectedServices = [];
var serviceTable = 'cmdb_ci_service'; // Or your specific service class table name

var serviceGR = new GlideRecord(serviceTable);
serviceGR.query(); // Query all services

while (serviceGR.next()) {
    var serviceSysId = serviceGR.getUniqueValue();
    var hasRelationship = false;

    // Check if it's a parent in ANY relationship
    var relParentGR = new GlideRecord('cmdb_rel_ci');
    relParentGR.addQuery('parent', serviceSysId);
    relParentGR.setLimit(1); // Optimization: we only need to know if at least one exists
    relParentGR.query();
    if (relParentGR.hasNext()) {
        hasRelationship = true;
    } else {
        // If not a parent, check if it's a child in ANY relationship
        var relChildGR = new GlideRecord('cmdb_rel_ci');
        relChildGR.addQuery('child', serviceSysId);
        relChildGR.setLimit(1); // Optimization
        relChildGR.query();
        if (relChildGR.hasNext()) {
            hasRelationship = true;
        }
    }

    // If no relationship was found either as parent or child
    if (!hasRelationship) {
        unconnectedServices.push(serviceGR.getValue('name') + ' (sys_id: ' + serviceSysId + ')');
        // Or add the sys_id to an array for further processing/reporting
    }
}

// Output the results
gs.info('Found ' + unconnectedServices.length + ' unconnected services: \n' + unconnectedServices.join('\n'));