- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 05:41 PM
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 05:57 AM
Jeah, i forgot one part. The below one should work:
function getParentTables(childTableName)
{
var parentTables = [];
var table = new GlideRecord('sys_db_object');
table.addQuery('name', childTableName);
table.addNotNullQuery('super_class');
table.query();
if(table.next())
{
var parentTableName = table.super_class.name;
parentTables.push(parentTableName);
// get the parents of the parent and appen it
parentTables = parentTables.concat(getParentTables(parentTableName));
}
return parentTables;
}
Greetings
Fabian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 04:38 AM
Hello,
I don't quite understand what the issue is. Do you need help with the scripting? Do you just need the information if this is possible?
It is in fact possible to do this. A functioni as follows will return you all names of the parent table structure.
function getParentTables(childTableName)
{
var parentTables = [];
var table = new GlideRecord('sys_db_object');
table.addQuery('name', childTableName);
table.addNotNullQuery('super_class');
table.query();
if(table.next())
{
var parentTableName = table.super_class.name;
parentTables.push(parentTableName);
// get the parents of the parent and appen it
parentTables.concat(getParentTables(parentTableName));
}
return parentTables;
}
Greetings
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 05:32 AM
I tried the above script, but I'm getting only one table, not the whole hierarchy
for 'cmdb_ci_computer'..I'm getting only 'cmdb_ci_hardware'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 05:57 AM
Jeah, i forgot one part. The below one should work:
function getParentTables(childTableName)
{
var parentTables = [];
var table = new GlideRecord('sys_db_object');
table.addQuery('name', childTableName);
table.addNotNullQuery('super_class');
table.query();
if(table.next())
{
var parentTableName = table.super_class.name;
parentTables.push(parentTableName);
// get the parents of the parent and appen it
parentTables = parentTables.concat(getParentTables(parentTableName));
}
return parentTables;
}
Greetings
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 06:06 AM
I'm getting output like
cmdb_ci_hardware,cmdb_ci,cmdb,
for 'cmdb_ci_computer'... I want it like
cmdb_ci_computer,cmdb_ci_hardware,cmdb_ci,cmdb,