- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 11:57 AM
I want to copy all the records in table A to table B.
Is there a way to copy in a script without using record export / import?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 12:01 PM
Hi @Carol543 ,
You can write a background script
var gr = new GlideRecord('tableA');
gr.query();
gr.setLimit(1); // test for 1 record after that use 100 or 500 as limit so that browser will not hang
while (gr.next()){
var rec = new GlideRecord("tableB");
rec.initialize();
rec.field = gr.field; // map the field name like this
rec.insert(); // insert to b table
}
Regards,
Gunjan Kiratkar
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 12:01 PM
Hi @Carol543 ,
You can write a background script
var gr = new GlideRecord('tableA');
gr.query();
gr.setLimit(1); // test for 1 record after that use 100 or 500 as limit so that browser will not hang
while (gr.next()){
var rec = new GlideRecord("tableB");
rec.initialize();
rec.field = gr.field; // map the field name like this
rec.insert(); // insert to b table
}
Regards,
Gunjan Kiratkar
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 12:06 PM
Let me try this script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 02:46 AM
Hi i have another requirement which is i created 5 tables with columns as A and B . In first table B column have value like 5 and it is a integer data type. Remaining 4 tables also have A and B columns and B columns have same value 5 Now i want to add all 5 table B column values like 5+5+5+5+5 and output will come as 25. I want to paste ouput in another new table which have Column name as output. Could you please suggest me the how can we write business rule for this scenario
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 12:02 PM
Is this a one time copy/data migration?
You can create a fix script or create a flow in flow designer (with a "run once" trigger)