How to map a tag based application service to a business service in servicneow

konijetis
Tera Contributor

Hi All, 

 

I have a requirement from client that azure, aws & OCI brings specific tags and values with SGC & Cloud discovery , but client want to create a tag based application services and add those to a Business service , OOB docs does not speake about how can i map these tag based application services to business services, 

 

appriciate your help in this if any once can help me how can i add the tag based application services to Business services.

3 REPLIES 3

Danish Bhairag2
Tera Sage

@konijetis ,

 

Tag-based Application Services created through Cloud Discovery are not automatically mapped to Business Services out of the box. OOB functionality focuses on creating the Application Service based on cloud tags, but the relationship to a Business Service needs to be established separately.

One approach is to use the cloud tags (or another common attribute) to identify the appropriate Business Service and then create the relationship using a Flow, Business Rule, or scheduled job. If your tagging strategy is consistent (for example, Business Service = Payroll), this mapping can be automated.

 

Thanks,

Danish Bhairagdar

we are able to get to the application service using cloud tags with tag based discovery process , could you help us with the BR how can we do the mapping of application service to a Businsess service.

@konijetis ,

 

Pls try this BR on Application Service table cmdb_service_auto. Replace the business service field value accordingly

 

(function executeRule(current, previous /*null when async*/) {

    // Read the Business Service tag from the Application Service
    // Replace 'u_business_service_tag' with your actual field name
    var bsName = current.u_business_service_tag;

    if (gs.nil(bsName))
        return;

    // Find the Business Service
    var bs = new GlideRecord('cmdb_ci_service');
    bs.addQuery('name', bsName);
    bs.query();

    if (!bs.next())
        return;

    // Check if relationship already exists
    var rel = new GlideRecord('cmdb_rel_ci');
    rel.addQuery('parent', bs.sys_id);      // Business Service
    rel.addQuery('child', current.sys_id);  // Application Service
    rel.query();

    if (!rel.next()) {

        // Get the relationship type
        var relType = new GlideRecord('cmdb_rel_type');
        relType.addQuery('name', 'Depends on::Used by');
        relType.query();

        if (relType.next()) {
            rel.initialize();
            rel.parent = bs.sys_id;
            rel.child = current.sys_id;
            rel.type = relType.sys_id;
            rel.insert();
        }
    }

})(current, previous);

 Thanks,

Danish Bhairagdar