- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 01:26 AM
Hi community,
we are trying to copy the data from Assessment instance table to a custom table we created with similar fields,
initially we want to copy all the data from Assessment table and after that we want to create a scheduled job that runs daily and copies all the assessments that are created that day, please help me with the script that will let us copy all the data to the custom table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 01:33 AM
Hi,
try below code
Note : replace incident table with assessment table and u_custom with your custom table name.
var gr = new GlideRecord('incident');
gr.query('active",'true');
if(gr.next()){
var gr1 = new GlideRecord('u_custom');
gr1.initialize();
gr1.u_name= gr.name;
gr1.u_number = gr.number;
gr1.insert();
}
Or create business rule on assessment table and try below code
var gr1 = new GlideRecord('u_custom');
gr1.initialize();
gr1.u_name= current.name; // replacefield name as per your requirement
gr1.u_number = current.number;
gr1.insert();
}
.
Please mark my response as correct answer or helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 02:57 AM
Hi Ankur,
I was able to copy all the data from assessment instance table to the custom table
below is the screenshots(both screenshots are of different records) of custom table and assessment instance table, the assessment instance Questions area data needs to be copied to the custom table
and the script only copied the data but not the responses, if I click on the view responses link at the bottom the responses are not showing
This is the custom table data
This is Assessment instance table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 03:51 AM
Hi Ankur,
Any update on this?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 05:56 AM
Hi,
check this link on how to copy including related list table data
Re: i want to copy the related list from a record to another record in the same table(say change)?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader