- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 03:00 AM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 03:34 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 03:47 AM
Yeah you are correct,
Actually my custom number field is of integer type thats why I faced problem.later I investigate and got to know that both fields types are different so I change that and it is giving me correct result.
Thanks Harshvardhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 03:50 AM
Sorry to disturb you again,
So far I have tried this in background script can we do this using another script technique?As I heard that background data insertion is not long lasting?Is it right or wrong?
Thanks,
Peter.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 03:57 AM
What is your exact requirement? Should this be done reguraly? Or is it a one time thing?
You could use for example:
- Background script (one time)
- Fix script (can be run in background, and if wanted mutliple times)
- Scheduled job (though my guess is this is a one time thing? because performing the script again would just make duplicate record?)
- Etc.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 05:06 AM
Thanks Mark,
But it is not for one time it is for several times.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2019 05:10 AM
Then Fix Script could be fine. Fix Script is saved, so easy to execute again, at any moment you want.
Though, concerning your current scripting, what about duplicates? I mean with the current scripting, you are just copying every record every time?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field