- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-30-2021 11:30 PM
In my previous Return list of table extensions using TableUtils() utility article, I had covered a few interesting extension functions from TableUtils() utility. In this article, I will cover additional functions (Few are extreme cautious 😱)
Alright, Let's jump into it
isBaseClass() : Returns true if the given class has no parents and has extensions.
var isBase = new TableUtils('cmdb').isBaseClass();
gs.print(isBase);
isSoloClass() : Returns true if the given class has no parents and no extensions
var isSolo = new TableUtils('sys_user_group').isSoloClass();
gs.print(isSolo);
hasExtensions() : Returns true if the given table has extensions
var hasExt = new TableUtils('cmdb_ci_server').hasExtensions();
gs.print(hasExt);
getAbsoluteBase(): Returns the root class of the table
var getBase = new TableUtils('cmdb_ci_server').getAbsoluteBase();
gs.print(getBase);
Note: Kindly, use the below functions with extreme caution
drop() : Drops the database table and its data eternally
var dropTable = new TableUtils().drop('u_from_scratch');
dropAndClean() : Drops the database table and cleans up the references to the table
var dropCleanTable = new TableUtils().dropAndClean('u_sample_table');
dropTableAndExtensions() : Drops the database table, all of its extended tables and cleans up references to the table
var dropTableExtensions = new TableUtils().dropAndClean('u_table');
I hope you like my article 😊
Kindly, Post comments if any corrections are required
Regards,
Sai Kumar
- 2,694 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sai,
I want to use TableUtils on my scope application to copy/duplicate a table structure in my scoped app. when tried, I was getting error "TableUtils" is not defined. Is it only going to work on global scope?
Just to test I ran the example script provide by you on Tokyo version on my custom application scope, I am getting following same error but on global scope it works.
var isBase = new TableUtils('cmdb').isBaseClass(); gs.print(isBase);
,
[0:00:00.060] Script completed in scope x_20949_ppt: script
Script execution history and recovery available here
Evaluator: com.glide.script.RhinoEcmaError: "TableUtils" is not defined. script : Line(1) column(0) ==> 1: var isBase = new TableUtils('cmdb').isBaseClass(); 2: gs.print(isBase);
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you're using scoped application, Try calling script include with API name in script. tableUtils() script include is only available for Global scope.