The CreatorCon Call for Content is officially open! Get started here.

Sai Kumar B
Mega Sage

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);

find_real_file.png

isSoloClass() : Returns true if the given class has no parents and no extensions

var isSolo = new TableUtils('sys_user_group').isSoloClass();
gs.print(isSolo);

find_real_file.png

hasExtensions() : Returns true if the given table has extensions

var hasExt = new TableUtils('cmdb_ci_server').hasExtensions();
gs.print(hasExt);

find_real_file.png

getAbsoluteBase(): Returns the root class of the table

var getBase = new TableUtils('cmdb_ci_server').getAbsoluteBase();
gs.print(getBase);

find_real_file.png

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');

find_real_file.png

dropAndClean() : Drops the database table and cleans up the references to the table

var dropCleanTable = new TableUtils().dropAndClean('u_sample_table');

find_real_file.png

dropTableAndExtensions() : Drops the database table, all of its extended tables and cleans up references to the table

var dropTableExtensions = new TableUtils().dropAndClean('u_table');

find_real_file.png

I hope you like my article 😊

Kindly, Post comments if any corrections are required 

Regards,
Sai Kumar

Comments
mkm1
Mega Guru

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);

 

Sai Kumar B
Mega Sage

@mkm1 

If you're using scoped application, Try calling script include with API name in script. tableUtils() script include is only available for Global scope.

 

Version history
Last update:
‎12-30-2021 11:30 PM
Updated by: