ServiceNow
Workflows

IT Workflows
Employee Workflows
Customer Workflows
Creator Workflows

IT Workflows
We offer workflows that can transform IT into a fully-fledged growth engine. Take advantage of the benefits of operational flexibility by increasing workforce adaptability...
Read More

Employee Workflows
Make employee experiences more integrated and engaging with ServiceNow Employee Workflows. Motivate your staff by making it simple for them to obtain what they require when they require it...
Read More

Customer Workflows
We connect clients, front-line agents, middle and back-office staff on a single ServiceNow platform with ServiceNow Customer Workflows using digital processes to scale customer operations...
Read More

Creator Workflows
With a low-code platform, you can quickly create digital workflow apps. Scale quickly across the organization to build natural, linked experiences that users enjoy...
Read More

Solutions
ServiceNow Solutions

IT Service Management
IT Operations Management
IT Asset Management
Governance, Risk, and Compliance
Security Operations

HR Service Delivery
Customer Service Management
Field Service Management
Integration Hub

IT Service Management
IT service management includes all the ServiceNow services and processes that ensure end to end...
Read More

IT Operations Management
ServiceNow ITOM consists of a set of modules in ServiceNow to manage the operations...
Read More

IT Asset Management
It is the set of business practices to manage the lifecycle of various assets in IT like software assets...
Read More

Governance, Risk, and Compliance
Almost every aspect of the business is driven by governance, risk, and compliance...
Read More

Security Operation
To minimize risk, ServiceNow SecOps allows you to immediately identify, prioritize, and respond to threats...
Read More

HR Service Delivery
With ServiceNow HRSD, you can increase company productivity and provide your employees...
Read More

Customer Service Management
Proactively solve problems and take actions to rectify common requests more efficiently with ServiceNow...
Read More

Field Service Management
ServiceNow Field Service Management enables you to efficiently and safely manage field service activity...
Read More

Integration Hub
For the fastest time to value, lowest TCO, and ease of use with zero learning curve for all ServiceNow developers...
Read More

Digital Transformation
Digital Transformation

DevOps
Robotic process automation
User Experience Design

DevOps
Devops includes the set of practices that automates the IT operations and accelerate the delivery...
Read More

Robotic process automationt
We help organizations to integrate different techniques like machine learning and artificial...
Read More

User Experience Design
User experience design is the creation of the effective flow between users and software...
Read More

Product Engineering
Product Engineering

IT Consulting
New Application development
Product testing & QA
Re-engineering & Migration
Support & maintenance

IT Consulting
We help Companies to Better their IT infrastructure and to Implement various IT strategies. Alignment of all the services to boost the overall performance...
Read More

New Application development
We are an IT service provider company using high-value business processes and technical stacks to build digital products...
Read More

Product testing & QA
We help clients to deliver quality products and services. Skilled Quality Assurance Team to perform a series...
Read More

Re-engineering & Migration
Re-Engineering and Migration is the concept of Comparing the Existing business model to the desired model...
Read More

Support & maintenance
We provide a range of support and maintenance services to our clients in the form of version upgrades, post-project support...
Read More

,

Table Hierarchy in Servicenow: Complete Guide

  • By Aelum consulting
  • April 1, 2021
  • 1897 Views

GlideTable Hierarchy is a ServiceNow Server scoped API which provides information about the Table hierarchy and relationships. We have TableUtils API which can be used to retrieve the hierarchy of tables in ServiceNow.

So How actually the Table Hierarchy API is useful?

TableUtils is limited to the global scope in ServiceNow and it cannot be accessed from scoped application. So there is either of ways to achieve this solution:

  1. Copy TableUtils inside the scoped application.
  2. writing logic for GlideRecord the “sys_db_object” table.

This solution implementation might take some additional effort for a developer. So here TableHierarchy API can be very useful to bring our efforts down and easy in implementation. To get the hierarchy of any table in scoped applications. The below methods will be useful.

 Method Summary:

Method Definition
GlideTableHierarchy(String tableName) Instantiates a GlideTableHierarchy object
getName() This method returns the table’s name
getTables() This method returns an array of strings containing table names in the hierarchy
getTableExtensions() This method returns an array containing the table names that extend the current table
getAllExtensions() This method returns an array containing the table names that extend the current table and includes the current table
getHierarchy() This method returns an array of all classes in the hierarchy of the current table
getRoot() This method returns the top-level class in the hierarchy
getBase() This method returns the parent class
isBaseClass() This method returns a boolean value, true if this is the base class 
isSoloClass() This method returns a boolean value, true if this is not part of any hierarchy
hasExtensions() This method returns a boolean value, true if the table has any child classes

In this Blog, We will drive through a few methods of this API with reference to the CMDB table hierarchy. For that we can use this API as follows:

API Definition: getTableExtensions() returns an array containing the table names that extend the current table.

Note: Current table will not be part of the return object. If you want to include the current table in the return object use getAllExtensions() method.

To fetch all the child tables(hierarchy) for the cmdb_ci_computer  table. We can use this method as explained below in the example.

Scoped Global
var hierarchy=new GlideTableHierarchy (‘cmdb_ci_computer’);var tables=hierarchy.getTableExtensions();gs.info(tables); var hierarchy= new TableUtils (“cmdb_ci_computer”);var tables=hierarchy.getTableExtensions();gs.info(tables);

 Output:

cmdb_ci_ucs_blade, cmdb_ci_server, cmdb_ci_osx_server, cmdb_ci_mainframe, cmdb_ci_datapower_server, cmdb_ci_lb, cmdb_ci_lb_bigip, cmdb_ci_lb_a10, cmdb_ci_lb_cisco_csm, cmdb_ci_lb_alteon, cmdb_ci_lb_f5_gtm, cmdb_ci_lb_cisco_gss, cmdb_ci_lb_isa, cmdb_ci_lb_cisco_css, cmdb_ci_lb_ace, cmdb_ci_lb_radware, cmdb_ci_lb_network, cmdb_ci_lb_netscaler, cmdb_ci_lb_f5_ltm, cmdb_ci_ibm_zos_server, cmdb_ci_virtualization_server, cmdb_ci_vcenter_server_obj, cmdb_ci_esx_server, cmdb_ci_hyper_v_server, cmdb_ci_storage_server, cmdb_ci_win_server, cmdb_ci_linux_server, cmdb_ci_storage_node_element, cmdb_ci_isam_server, cmdb_ci_mainframe_lpar, cmdb_ci_server_hardware, cmdb_ci_tape_server, cmdb_ci_net_app_server, cmdb_ci_chassis_server, cmdb_ci_netware_server, cmdb_ci_unix_server, cmdb_ci_aix_server, cmdb_ci_solaris_server, cmdb_ci_hpux_server, cmdb_ci_cim_server, cmdb_ci_storage_switch, cmdb_ci_mainframe_hardware, cmdb_ci_pc_hardware, cmdb_ci_ucs_rack_uniAPI Definition: getHierarchy() returns an array of all classes in the hierarchy of the current table.

Scoped Global
var hierarchy=new GlideTableHierarchy(‘cmdb_ci_computer’);var tables=hierarchy.getHierarchy();gs.info(tables); var hierarchy= new TableUtils(“cmdb_ci_computer”);var tables=hierarchy.getHierarchy();gs.log(tables);

 Output:

cmdb_ci_computer, cmdb_ci_hardware, cmdb_ci, cmdb, cmdb_ci_ucs_blade, cmdb_ci_server, cmdb_ci_osx_server, cmdb_ci_mainframe, cmdb_ci_datapower_server, cmdb_ci_lb, cmdb_ci_lb_bigip, cmdb_ci_lb_a10, cmdb_ci_lb_cisco_csm, cmdb_ci_lb_alteon, cmdb_ci_lb_f5_gtm, cmdb_ci_lb_cisco_gss, cmdb_ci_lb_isa, cmdb_ci_lb_cisco_css, cmdb_ci_lb_ace, cmdb_ci_lb_radware, cmdb_ci_lb_network, cmdb_ci_lb_netscaler, cmdb_ci_lb_f5_ltm, cmdb_ci_ibm_zos_server, cmdb_ci_virtualization_server, cmdb_ci_vcenter_server_obj, cmdb_ci_esx_server, cmdb_ci_hyper_v_server, cmdb_ci_storage_server, cmdb_ci_win_server, cmdb_ci_linux_server, cmdb_ci_storage_node_element, cmdb_ci_isam_server, cmdb_ci_mainframe_lpar, cmdb_ci_server_hardware, cmdb_ci_tape_server, cmdb_ci_net_app_server, cmdb_ci_chassis_server, cmdb_ci_netware_server, cmdb_ci_unix_server, cmdb_ci_aix_server, cmdb_ci_solaris_server, cmdb_ci_hpux_server, cmdb_ci_cim_server, cmdb_ci_storage_switch, cmdb_ci_mainframe_hardware, cmdb_ci_pc_hardware, cmdb_ci_ucs_rack_unit

API Definition: getRoot() returns the top-level class in the hierarchy.

For Global, a Similar method is getAbsoluteBase() which returns the base table name from which the table was extended.

Note: For any table under the cmdb_ci hierarchy, this method returns cmdb_ci and not CMDB, which is the actual base table.

 

Scoped Global
var hierarchy=new GlideTableHierarchy(‘cmdb_ci_computer’);var tables=hierarchy.getRoot();gs.info(tables); No similar Method available

 

Output:

cmdb

API Definition: getBase() returns the parent class which current class is extending like task(return) for incident(argument).

 

Scoped Global
var hierarchy=new GlideTableHierarchy(‘cmdb_ci_computer’);var tables=hierarchy.getBase();gs.info(tables); No similar Method available

 

Output:

Cmdb_ci_hardware

Thanks You for Readings

For More Contents on Service Now go to Aelum Consulting Blogs

 

1 thought on “Table Hierarchy in Servicenow: Complete Guide”