Seeking an Approach to Manage Dependent CIs Aligned with ServiceNow IRE Best Practices

ritik16
Tera Contributor

Hello Everyone,

Hope you all are doing well!

We have a requirement to replace the custom Business rule functionality that checks if a corresponding Network Adapter (NIC) and IP Address record already exist for the current Configuration Item (CI). If they do not exist, the script creates the necessary cmdb_ci_network_adapter and cmdb_ci_ip_address records, linking them to the current CI.

We are looking for an approach aligned with ServiceNow’s Identification and Reconciliation Engine (IRE) framework best practices.

If anyone has any prior experience working with IRE, your insights would be greatly appreciated.

Thank you in advance.


4 REPLIES 4

srinija_itom
Tera Guru
Tera Guru

Hi @ritik16

 

Could you please explain the logic how  the script creates the necessary cmdb_ci_network_adapter and cmdb_ci_ip_address records, linking them to the current CI? 

 

Regards, 

 

Srinija

Hii @srinija_itom,

The before business rule is applied insert and update on configuration item (cmdb_ci) table. There is a custom created field called LM IPs (u_lm_ips) on the cmdb_ci table, if this field changes or not empty then the Business rule will be triggered.
Below is the script used in the business rule:

(function executeRule(current, previous /null when async/) {
    var ips = current.u_lm_ips;
    var ipsSplit = ips.toString().split(',');

    for (var i = 0; i < ipsSplit.length; i++) {

        var grNIC = new GlideRecord("cmdb_ci_network_adapter");
        grNIC.addQuery("ip_address", ipsSplit[i]);
        grNIC.addQuery("cmdb_ci", current.sys_id);
        grNIC.query();

        //if an existing NIC is not found then create it and related IP address record
        if (!grNIC.next()) {
            grNIC.initialize();
            grNIC.name = "NIC_" + ipsSplit[i];
            grNIC.ip_address = ipsSplit[i];
            grNIC.cmdb_ci = current.sys_id;
            grNIC.netmask = current.u_lm_netmask;
            grNIC.company = current.company;
            var newNIC = grNIC.insert();

            //requery the new record to set the domain
            grNIC.get(newNIC);
            grNIC.update();

            //create the related IP address
            var grIP = new GlideRecord("cmdb_ci_ip_address");
            grIP.initialize();
            grIP.ip_address = ipsSplit[i];
            grIP.netmask = current.u_lm_netmask;
            grIP.ip_version = '4';
            grIP.nic = newNIC;
            grIP.company = current.company;
            var newIP = grIP.insert();
           
                //requery the new record to set the domain
            grIP.get(newIP);

        }

    }




})(current, previous);

Hi @ritik16 , 

 

Thank you for the script. Are these configuration items created via servicenow discovery or manual import of data. 

Regards, 

 

srinija

 

 

Hello @srinija_itom 
The configuration items are created via a data source import.

We have some doubts about whether it’s possible to use the Robust Transformer to create associated child records in the Network Adapter and IP Address tables when the related CMDB CI’s custom fields (containing IP addresses) are updated through integration and the corresponding child records don’t already exist in specified classes (Network Adapter and IP Address).

Thank you.