How to get the parent table name of a record in a child table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 10:14 AM
Hi, how would I get the parent table name of a record?
For example, cmdb_ci_netgear table extends cmdb_ci_hardware table.
The code looks as follows:
var ci = new GlideRecord('cmdb_ci_hardware');
ci.get('123456789'); //looking for a specific sys_id in the Hardware table - in this case just random numbers
gs.addInfoMessage(ci.sys_class_name);
This code returns "cmdb_ci_netgear", but how do I make it return "cmdb_ci_hardware" by looking up what the parent table is of that particular record? In other words, how to dot walk use a record in cmdb_ci_netgear table to figure out what its parent table is.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 10:18 AM
You could do:
var ci = new GlideRecord('cmdb_ci_hardware');
ci.get('123456789');
var tu = new TableUtils(ci.sys_class_name);
var tables = tu.getTables()
var arrayUtil = new ArrayUtil();
var parentTable = arrayUtil.convertArray(tables)
parentTable = tables[1]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 12:16 PM
Hi ,
Please refer below link:
thanks,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2020 03:56 AM
Hey Mike,
I've used below code to get data of Problem table's parent Incident in Business Rule. Maybe this code will help you figure out your solution:
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent); //Current is for Problem Table in my case
gr.query();
If my reply helps then please mark it Helpful as well as Correct.
Thanks and Regards:
Utpal Dutta
DxSherpa Pvt. Ltd.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2020 04:21 AM
current.parent in your addQuery condition should do the trick.
Please Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if it helps resolve your problem.
Thanks,
Saji