Advanced Integration of ServiceNow with netTerrain
ServiceNow, a cloud-based platform that provides a single view of IT, operations, and business management, is used by organizations of all sizes to automate workflows, improve efficiency, and deliver better customer experiences.

As you may know, ServiceNow’s platform is based on the ITIL framework, which is a set of best practices for IT service management.

ServiceNow platform

The platform includes a wide range of features, such as:

  • Ticketing: ServiceNow can be used to create and track tickets for IT incidents, requests, and changes.
  • Self-service: Users can access knowledge articles, collaborate with others, and submit requests through a self-service portal.
  • Automated workflows: ServiceNow can automate workflows, such as incident resolution and change management.
  • Reporting and analytics: ServiceNow provides reports and analytics to help organizations track their IT performance.

Back in 2019, we wrote a blog about the ServiceNow integration with our IT visualization/documentation software netTerrain, however, a lot’s changed since then. netTerrain’s connector to ServiceNow (as of 2023*) is a vast improvement over the previous connector we had. Not only does netTerrain support a wide array of entities that can be imported from SNOW, but it can also push data from netTerrain back into service, including the ability to update ServiceNow when a netTerrain event is triggered.

Integration basics

netTerrain’s integration with ServiceNow is accomplished using the Collector (netTerrain’s native discovery engine) and a SNOW connector available as a dll (ServiceNowConnector.dll plugin) for pushing data back to netTerrain.

For the write back (or push) capability, a user can create a trigger which can be launched on object field changes or a detailed user action, such as a rack position change of a device.

Predefined triggers can contain exact values of properties so the SNOW API is called only when a combination of values matches or it can be defined as a general trigger, such that the API is called simply when something is changed.

Setting up ServiceNow in the collector

To read from ServiceNow, you just need to configure the Snow connector in the Collector. As with all connectors in netTerrain, it’s simple.

The ServiceNow connector can pull information from an account using the classic REST-API pull approach (where it connects to your account via a user, a password, and a REST endpoint).

ServiceNow connection information
ServiceNow connection information

After you’ve tested that your connection’s working, you can specify which entity names need to be imported into netTerrain by using the advanced settings.

Currently, the connector can pull data for the following entities:

  • Application
  • BigIp
  • Circuit
  • CMDB
  • Computer room AC
  • Hardware
  • IP device
  • IP firewall
  • IP phone
  • IP router
  • Netscaler
  • Outlet
  • Servers full
  • Stock room
  • UC warranty
  • UC warranty support level
  • Users brief
  • Warranty

ServiceNow advanced connector
ServiceNow advanced connector settings

Above, I mentioned that the expanded ServiceNow connector in version 9.7 of netTerrain not only lets you specify multiple table mappings and field mappings between ServiceNow and netTerrain but you can also establish relationships between child and parent tables and insert, update, and delete objects in ServiceNow as they change in netTerrain.

To take a deeper dive, netTerrain’s ServiceNow Connector methods include:

  1. UpdateServiceNowField(string nodeId, string propertyName): updates SNOW table according to mapping specifications
  2. AddServiceNowInstance(string nodeId): creates a SNOW record
  3. AddServiceNowInstanceWithRelationship(string nodeId): creates a SNOW record and relationship based on mapping specifications
  4. DeleteServiceNowInstance(string nodeId): deletes SNOW record
  5. CreateServiceNowRelationships(string nodeId): creates a relationship

The configuration of the write-back capability, along with the mapping of entities, fields and triggers is done in a special Json file supplied with the connector (ServiceNowConnector.json) and the information flows directly from netTerrain into ServiceNow — without passing through the Collector.

The connector supports CMDB relationships, comboboxes, and triggers (aka a record in ServiceNow that’s being created, deleted or updated based, for example, on a property change event in netTerrain).

Triggers and record changes in ServiceNow are managed through netTerrain custom actions.

The first step in the write-back configuration is to establish the Key Mappings. This, along with the rest of the configuration, is done in the ServiceNow Json file.


Key Mapping Configuration

An example of the key mapping configuration is as follows:

"KeyMapping": 
{ 
    "SN_KeyField": "u_unique_id_vista", 
    "NT_KeyField": "Name"
}

Table Mapping

The table mapping section in the Json config file lets you establish relationships between an entity in netTerrain and the corresponding table in ServiceNow that needs to be updated:

"TableMapping": 
{ 
    "NT_SourceField": "ASSET_CLASS", 
    "ValueToTables": [ 
        { 
            "NT_Value": "SERVER", 
            "SN_Table": "cmdb_ci", 
            "FieldMapping": [ 
                { 
                    "NT_Field": "Comments", 
                    "SN_Field": "comments" 
                }, 
                {
                    "NT_Field": "[Parent]Name",
                    "SN_Field": "u_stockroom", 
                    "AlwaysUpdate": "true"
                } 
            ] 
        } 
    ] 
}

In this example If ntTable[“ASSET_CLASS”] == “SERVER” Then we use Snow Table “cmdb_ci” for requests and NT field “Comments” of source Node is linked to SNOW “cmdb_ci.comments”. TableMapping.ValueToTables. FieldMapping.AlwaysUpdate this flag attach marked field to any triggered update for this table. So even if we update “Comments” in our example, the name of parent will be attached as u_stokroom. Here [Parent] markup means to get value from parent and [Parent(2)] will get value from grandparent. There are some special nt fields: “[Id]” which retrieve Id of the node, “[RackPosition]” – gets rack position and Type to get name of the node type.


Field Mapping

FieldMappings.NT_TableWithSNSysId is used to convert list values from NT combo boxes to SNOW values.

Example:

"NT_TableWithSNSysId": 
{
    "Nt_Table": "adisc_raw_ServiceNow_CMDB_ENT",
    "SysIdField": "sys_id", 
    "ValueField": "name"
}

So, this mapping gets value from NT table like this:

$"SELECT TOP 1 [{SysIdField }] FROM { Nt_Table } WHERE [{ValueField }] = '{ntPropValue}'"

where ntPropValue is the one selected in combobox.


Relationship Rules

This part is used to create a relationship between ChildTable and ParentTable.

Example:

"RelationshipRules": 
[ 
    { 
        "ChildTable": "u_cmdb_ci_blade_server", 
        "ParentTable": "cmdb_ci_chassis_server", 
        "Type": "55c95bf6c0a8010e0118ec7056ebc54d" 
    } 
]

Basically, we search sys_id for these tables snSysId and snParentSysId by SN_KeyField and NT_KeyField. Then, we search relSysId by Type in the “api/now/table/cmdb_rel_ci” And delete it. Then we create a new one by request “api/now/cmdb/instance/{relationship.ChildTable}/{snSysId}/relation”.


Triggers

Triggers are configured as custom actions in netTerrain, such as the example below:

<CustomUserAction>
    <Name>Push to ServiceNow</Name>
    <Action>runextmethod</Action>
    <Filter>nodes</Filter>
    <Parameters>
        <Module>ServiceNowConnector.dll</Module>
        <Method>AddServiceNowInstanceWithRelationship</Method>
        <MethodParameters>
            <Id>[Id]</Id>
        </MethodParameters>
    </Parameters>
</CustomUserAction>

In sum, ServiceNow’s cloud-based platform is constantly evolving — as is netTerrain. Our engineering team is committed to providing flexible, in-depth, updated, and user-friendly integrations with leading platforms (learn more about other netTerrain connectors here).

With this latest ServiceNow connector, the integration between both systems effortlessly bridges data transfers, encompasses a broader range of entities, and instantaneously mirrors updates. The advanced integration capabilities of netTerrain’s ServiceNow connector give you a seamless experience in establishing comprehensive mappings and relationships between ServiceNow and netTerrain.

*The information and code snippets provided in this article represent a summary and reflect the development at the time of writing. Some of the code may be incomplete or may have undergone changes after the publication of this article. We always recommend consulting with our support team or referring to the latest documentation for the most up-to-date and accurate information.

About Nadia Sharabarova

Nadia serves as the principal engineer for Graphical Networks: she has been an integral member of the team since 2012. If you use any netTerrain product, you are probably running her code. A computer science and mathematics graduate from Irkutsk State University, Nadia is known for her ability to figure out anything and everything. When Nadia is not busy perfecting netTerrain, she can be found winning hands at poker or embarking on another adventure around the globe. She plans to add Antarctica to her list one of these days.