Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

clone copy a table in 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);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: java script names starting with b foreach 
Javascript :: comment creer des switch en react js 
Javascript :: reactnative sliding image 
Javascript :: how to escape double quotes in json 
Javascript :: java script loup object 
Javascript :: shopify hover effect 
Javascript :: react native paper touchable ripple 
Javascript :: how to add multiple quill rich text editor 
Javascript :: how to trigger a function after stop writing in input text jquery event 
Javascript :: implict type coercion in js 
Javascript :: find longest even string in array javascript 
Javascript :: loop with multiple conditions js codesmith 
Javascript :: koa get post body 
Javascript :: 4.6.3. Order of Operations¶ 
Javascript :: applicature 
Javascript :: How to change color of an icon, text or other component with ReactNative useState Hook 
Javascript :: javascript intersection reduce, filter, includes 
Javascript :: HimalayanCoffeeHouse Noida 
Javascript :: Changing Async/Await to Promises.all to Speed Up API Calls in Node.JS 
Javascript :: serverless web app with react netlify 
Javascript :: outlet context remix js 
Javascript :: Example code of using inner blocks in Wordpress with ESNext 
Javascript :: angular 8 input decorator Expected 2 arguments, but got 1. 
Javascript :: isFinite(): returns true if the number is not Infinity or -Infinity 
Javascript :: react native red Half Circle bubble 
Javascript :: keep form values after submit javascript 
Javascript :: space station json file 
Javascript :: use this in a react js component 
Javascript :: preventClosingTab 
Javascript :: create elements 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =