- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 11:58 AM
Hi All,
I'm trying to copy specific(not all) 'sys_choice' Category values of Incident table to another custom table --
I'm using the below job/script to insert same records as incident - However it is creating only one record in sys_choice with new table value. Am i missing anything below?
var gr = new GlideRecord('sys_choice');
gr.addEncodedQuery('nameSTARTSWITHINCIDENT^elementSTARTSWITHcategory^dependent_valueSTARTSWITHdata');
gr.query();
while(gr.next()) {
var gr1 = new GlideRecord('sys_choice');
gr1.initialize();
gr1.name = 'u_finance';
gr1.element = 'u_task_category';
gr1.label = gr.label;
gr1.value = gr.value;
gr1.dependent_value = gr.dependent_value;
gr1.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2018 07:17 AM
Pradeep,
Even the Rowcount is 20 in the script.
Anyhow i figured the root cause of this issue. There was a BR in background "choice unload" causing this script to not execute completely. I have added setWorkflow(false) in my Script and it worked now. Thank you responding here. Appreciate it 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 02:39 PM
Hi Chandu,
Can you apply the same filter i.e nameSTARTSWITHINCIDENT^elementSTARTSWITHcategory^dependent_valueSTARTSWITHdata' and from UI and check the count of records once?
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 03:00 PM
Pradeep,
The count is 20 in the UI. but when i run the job, it is getting only 1 record inserted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 03:17 PM
Thanks for the update. Can you log the Row Count in the script as well and check it once?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2018 07:17 AM
Pradeep,
Even the Rowcount is 20 in the script.
Anyhow i figured the root cause of this issue. There was a BR in background "choice unload" causing this script to not execute completely. I have added setWorkflow(false) in my Script and it worked now. Thank you responding here. Appreciate it 🙂