FujiForty - Table Hierarchy API

One of the powerful and efficient concepts found in the ServiceNow platform is the ability to extend existing table schemas. This not only makes table creation faster and easier, it also allows you to inherit business processing logic and report on an aggregate of data across hierarchical tables. For example, a worker can display all of their work in a single queue even though the data appears to be in different tables.

Many times when building business process scripts we need to understand this hierarchical structure of a table we are working with. In the past, the TableUtils API was available to help us. With the introduction of application scopes and related API change in Fuji, TableUtils is now limited to global scope scripts. The replacement for scoped applications is GlideTableHierarchy. It doesn't cover everything that TableUtils does but you'll find that it does handle the majority of cases that you'd need, such as determining if a table has extensions, is extended from another table, and what it's base table is. You can even get the full hierarchy of tables.

Here's a quick example:

var gth = new GlideTableHierarchy("cmdb_ci_server");
gs.debug("Parent tables: " + gth.getTables());
gs.debug("Extensions: " + gth.getTableExtensions());
Parent tables: cmdb_ci_server,cmdb_ci_computer,cmdb_ci_hardware,cmdb_ci
Extensions: cmdb_ci_mainframe,cmdb_ci_osx_server,cmdb_ci_linux_server,....