54. GlideTableHierarchy API
There are two scripts (option 1 & 2) that can be used to get information about table relationships and all tables that extend the current table.
However, if you use ServiceNow GlideTableHierarchy API’s getAllExtensions() methods in option 2 script, you can get the same information with fewer codes rather than the complex codes in option 1 script
Correction for the image:
Option 1 is
var parentName = ‘sn_hr_core_case’;
getExtendedChildedTableName(parentName);
function getExtendedChildedTableName(parentName) {
var grDBObject = new GlideRecord(‘sys_db_object’);
grDBObject.addQuery(‘super_class.name’, parentName);
grDBObject.query();
while (grDBObject.next()) {
gs.print(grDBObject.name);
}}
Output:
*** Script: sn_hr_core_case_workforce_admin
*** Script: sn_hr_core_case_talent_management
*** Script: sn_hr_core_case_payroll
*** Script: sn_hr_core_case_total_rewards
*** Script: sn_hr_core_case_operations
*** Script: sn_hr_core_case_corporate_communication
*** Script: sn_hr_core_case_benefits
*** Script: sn_hr_core_case_global_mobility
*** Script: sn_hr_core_case_compensation
Option 2 is
var table = new GlideTableHierarchy();
gs.info(table.getAllExtensions());
https://medium.com/@LearnITbyPrashant/54-glidetablehierarchy-api-a007b16e9379?source=rss-d005fc598f0a------2