clone copie uma tabela em serviceNow
cpTable('sys_upgrade_history_log', 'u_testcase', true);
function cpTable(strOldTable, strNewTable, bCopyIndexes) {
var tu = new TableUtils(strNewTable);
var bNewTableAlreadyExists = tu.tableExists();
if (bNewTableAlreadyExists) {
gs.print("WARNING: Target Table " + strNewTable + " already exists! Please choose a new target table name");
} else {
var gr = new GlideRecord(strOldTable);
gr.initialize();
var td = GlideTableDescriptor.get(strOldTable);
var tdNewTable = new SNC.TableRotationBootstrap(strNewTable, gr.getLabel());
var dbo = new GlideRecord("sys_db_object");
dbo.addEncodedQuery("super_classISNOTEMPTY^name=" + strOldTable);
dbo.setLimit(1);
dbo.query();
if (dbo.next()) {
tdNewTable.setExtends(dbo.super_class.name + '');
}
tdNewTable.setFields(gr);
tdNewTable.copyAttributes(td);
tdNewTable.create();
if (bCopyIndexes) {
tdNewTable.copyIndexes(strOldTable, strNewTable);
}
}
}
Envious Elk