Copy records from one table to another tables using script.

Peter Wood
Kilo Guru

I have two tables "ABC" and "PQR".Both table contains same fields. In ABC table I have 100 records I want to pull all 100 records in table PQR using script.How to do that?

1 ACCEPTED SOLUTION

i tested with below code in my persona instance. i create custom number field on my custom table and its string type field and it has copied the incident number to the custom number field. 

 

var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){

var gr1 = new GlideRecord('u_custom');
gr1.initialize();
gr1.u_name= gr.short_description;
gr1.u_number = gr.number;
gr1.insert();

 

}

View solution in original post

14 REPLIES 14

Could this work as a Client Scrip on the source table?

Copying this field from Legal to a custom table

you can use here fix script  and set the script inside there.

please add the exact need , so we we can guide you in right way. 

Thanks harshvardhan.

If I required something on it will let you know.

Doc link about fix script .

 

https://docs.servicenow.com/bundle/newyork-application-development/page/build/applications/concept/c...

 

let me know if you need any further help here. 

where we write this script in business rule or client script or schedule job?