TableUtils not working in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 04:13 PM
I have included TableUtils in script include (not working)..however it worked when I ran in background script
var tu = new global.TableUtils(sysClass);
var classHierarchy = tu.getTables().toArray();
ciClassH=classHierarchy.join(':');
var ciParentTable=['cmdb_ci_hardware','cmdb_ci_appl','cmdb_ci','cmdb_ci_netgear','cmdb_ci_server'];
var hierarchyName=['Hardware Hierarchy','Application Instance Hierarchy','Independent Hierarchy','Network Hierarchy','Server Hierarchy'];
for(var x=0;x<classHierarchy.length;x++)
{
var arrayUtil = new ArrayUtil();
if(arrayUtil.indexOf(ciParentTable, classHierarchy[x])>-1)
{
TableHierarchy=
hierarchyName[arrayUtil.indexOf(ciParentTable,classHierarchy[x])];
break;
}
}
tableHierarchy=TableHierarchy;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 05:07 PM
Add few debug statements in your script include to identify whats going wrong. Also i change line marked in bold below. please try again
var tu = new global.TableUtils(sysClass);
var classHierarchy = tu.getTables().toArray();
ciClassH=classHierarchy.join(':');
var ciParentTable=['cmdb_ci_hardware','cmdb_ci_appl','cmdb_ci','cmdb_ci_netgear','cmdb_ci_server'];
var hierarchyName=['Hardware Hierarchy','Application Instance Hierarchy','Independent Hierarchy','Network Hierarchy','Server Hierarchy'];
for(var x=0;x<classHierarchy.length;x++)
{
var arrayUtil = new ArrayUtil();
if(arrayUtil.indexOf(ciParentTable)>-1)
{
TableHierarchy=
hierarchyName[arrayUtil.indexOf(ciParentTable)];
break;
}
}
tableHierarchy=TableHierarchy;
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 05:55 PM
Hi , only the below script is not working
var tu = new global.TableUtils(sysClass);
var classHierarchy = tu.getTables().toArray();
ciClassH=classHierarchy.join(':');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 07:05 PM
What is the value of sysClass? Has it been defined somewhere?
More of question from my side, doesn't the getTables method give the array of hierachy table list. So do you need toArray still?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 07:56 PM
One more thing. As getTables underTableUtils gives a arraylist. Hence you need to use j2js to convert to java script array type.
var tu = new global.TableUtils(sysClass);
var classHierarchy = j2js(tu.getTables());//this give javascript array of the hierarchy tables of sysClass table that you have defined.