- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 02:22 AM
All,
Is there an easy way to just get the parent table of a current table? I have an array of model categories - cmdb_ci_win_server, cmdb_ci_linux_server and cmdb_ci_server. In this scenario, cmdb_ci_server is the parent of both the other model categories. Is there an easy way to identify the parent in this case via script? I looked at the tableutils script include and that gives hierarchy array. I was hoping for something simpler like getParent(). Any ideas?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 02:38 AM
Hello ncp
In the way you commented with the TableUtils what about to use getTables()?
If you are looking the "parent" of the incident table you obtain [incident, task]
Please, mark correct or useful if I helped you
Thanks
Ariel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 02:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 03:31 AM
Thanks Ariel, I was hoping for a simple getParent(), for cmdb_ci_win_server I get the following, so have to go through those,but if thats the only option then I dont have a choice. Thanks for your input. If I dont get a better answer I will mark yours as the correct one ariel
cmdb_ci_win_server, cmdb_ci_server, cmdb_ci_computer, cmdb_ci_hardware, cmdb_ci, cmdb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 04:44 AM
Hi ncp,
Checkout the TableUtils script include for some helpers. getTables() will return all the parent tables, the last entry is the base table.
var tu = new TableUtils("cmdb_ci_win_server");
var tables = tu.getTables();
//tables = [cmdb_ci_win_server, cmdb_ci_server, cmdb_ci_computer, cmdb_ci_hardware, cmdb_ci]
One clarification regarding the user of getTableName() - the result can vary depending on the GlideRecord.
Say I have INC0010003, and I have an "incident" GlideRecord for that sys_id. getTableName() will give "incident". If, however, my GlideRecord is on "task" for that same record, getTableName() will give "task".
getRecordClassName(), on the other hand, will give "incident" for both. It returns the sys_class_name value. For conditions on class, it is often more reliable.
Let me know, if you have any question.
Please mark it Correct or Helpful, if it works based on impact...!!!!
Thanks,
Priyanka
www.dxsherpa.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 04:54 PM
May someone know how to do the same thing using only the API?
Thanks,
Ani