logo

NJP

TableUtils() utility additional functions

Import · Dec 31, 2021 · article

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

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

image

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

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

image

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

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

image

getAbsoluteBase(): Returns the root class of the table

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

image

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

image

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

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

image

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

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

image

I hope you like my article image

Kindly, Post comments if any corrections are required

Regards,

Sai Kumar

View original source

https://www.servicenow.com/community/developer-articles/tableutils-utility-additional-functions/ta-p/2312768