How can we move data from one table to another using fix script?

Gaurav Bhardwaj
Tera Contributor

Hi All,

 

I want to move some records from one table to another table using the fix script. 

Both tables are extending the same table. 

I have drafted below script but it seems to be tedious work to map each and every column of both tables, Is there any way we can move these data without mapping when the table columns are same. 

 

var gr = new GlideRecord("old_table");

gr.addEncodedQuery("query");

gr.query();

gr.autoSysFields(false);
gr.setWorkflow(false);


while(gr.next()) {
var newGr = new GlideRecord("new table");


newGR.field_name1 = gr.field_name1.toString();

newGR.field_name2 = gr.field_name2.toString();
//add the remaining fields one by one.
newGr.insert();
}

0 REPLIES 0