CIUtils - Global

CIUtils is a utility class for working with configuration items.

By default, when traversing CI relationships the system will use a max depth of 10. This can be overridden in the glide.relationship.max_depth property.

The maximum number of items returns is 1000. This can be overridden in the glide.relationship.threshold property.

The CIUtils class is available to server-side script.

CIUtils - servicesAffectedByCI(String CI_sys_id)

Determine which business services are affected by a specific CI.

Table 1. Parameters
Name Type Description
CI_sys_id String The sys_id of a configuration item (cmdb_ci)
Table 2. Returns
Type Description
Array An array of sys_id values for cmdb_ci records downstream of (or affected by) the specified item.

var CIUtil = new CIUtils();
 
//get a server record
var server = new GlideRecord("cmdb_ci_server");
server.addQuery("name", "lnux100");
server.query();
if (server.next()) {
  //get the affected services, array of ids
  var serviceIds = CIUtil.servicesAffectedByCI(server.getUniqueValue());
  for (var i=0; i < serviceIds.length; i++) {
    //get the service record
    var service = new GlideRecord("cmdb_ci_service");
    service.get(serviceIds[i]);
    gs.print(service.getDisplayValue());
  }
}
Output:
Client Services
IT Services
Bond Trading

CIUtils - servicesAffectedByTask(GlideRecord task)

Determine which business services are affected by a task.

Table 3. Parameters
Name Type Description
task GlideRecord A task GlideRecord, for example incident, change_request, problem
Table 4. Returns
Type Description
Array An array of sys_id values for CIs downstream of (or affected by) the configuration item referenced by the task's cmdb_ci field.

var CIUtil = new CIUtils();
 
//get an incident record
var inc = new GlideRecord("incident");
inc.addQuery("number", "INC00050");
inc.query();
if (inc.next()) {
  //get the affected services, array of ids
  var serviceIds = CIUtil.servicesAffectedByTask(inc);
  for (var i=0; i < serviceIds.length; i++) {
    //get the service record
    var service = new GlideRecord("cmdb_ci_service");
    service.get(serviceIds[i]);
    gs.print(service.getDisplayValue());
  }
}
Output:
IT Services
Email
Windows Mobile
Electronic Messaging
Outlook Web Access (OWA)
Blackberry