How to replicate incident table in a new custom table without Extending it from Incident.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 12:21 AM
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 05:28 AM
Hi @harshchaudh You can run this script in background for copying table for testing purpose
cpTable('incident', 'u_incident', true); //Original table incident, new table u_incident
function cpTable(strOldTable, strNewTable, bCopyIndexes) {
var tu = new TableUtils(strNewTable);
if (tu.tableExists()) {
gs.print("Table already exists: " + strNewTable);
return;
}
var gr = new GlideRecord(strOldTable);
gr.initialize();
var td = GlideTableDescriptor.get(strOldTable);
var tdNewTable = new SNC.TableRotationBootstrap(strNewTable, gr.getLabel());
// Extend if super class found
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);
}
// Force reload of table schema in memory
GlideTableManager.invalidateTable(strNewTable);
GlideCacheManager.invalidateAll();
gs.print("Table '" + strNewTable + "' copied from '" + strOldTable + "' with fields.");
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2025 05:12 AM
Hi @harshchaudh
Did you try this?