- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 06:35 AM
Hello Experts,
I'm trying the script below to force update ALL records so the calculated field values gets written in the database, so then I can filter/sort on the calculated fields to run proper reports. The problem I'm having with the background script below is that it keeps saying 'running transaction' for a long time before I end up clicking 'Cancel'.
Any thoughts on how I can update the table to force update all the records to save the calculated values to the DB?
var gr = new GlideRecord('change_request');
gr.query();
while (gr.next()) {
gr.setForceUpdate(true);
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.update();
}
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 06:54 AM
Hi Brown,
I would suggest you to use fix script since using this will allow you to check the status in background. This fix script can run in background and you can monitor that using Progress Workers under System Diagnostics.
https://docs.servicenow.com/bundle/kingston-application-development/page/build/applications/concept/c_FixScripts.html
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2018 06:39 AM
Hi Brown,
That is not an issue. These warnings are shown whenever you try to execute fix scripts. Fix scripts basically helps to monitor the script status etc.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 06:55 AM
Hey,
Instead of trying on whole change table record, try using chooseWindow
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&type=server&scoped=true&to=method_class__scoped_choosewindow_number_firstrow__number_lastrow__boolean_forcecount__gliderecord__geneva&id=r_ScopedGlideRecordChooseWindow_Number_Number_Boolean
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 07:38 AM
Hi Rahul,
I'm not sure I understand how this is suppose to work. I looked at the link you posted, but not clear on how this line of code works, and what it actually pulls - 'gr.chooseWindow(2, 4);'
Would you be able to help me with this for my situation? I have 3 fields that are calculated values on each record, and I need to get those pushed to the DB, so I can properly filter & sort on it.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 07:43 AM
Sure thing.
gr.chooseWindow(2, 4); // here you give start and end limit. example, out of 100 record if you want to query only for 25th to 35th record which is based on some ascending condition, query would be like below
gr.chooseWindow(25, 35);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 07:54 AM
Oh okay, not sure if this would be a good option for me though. There are over 300+ active records which has these calculated values that I am trying to push the to the DB. Most of these records existed prior to creating the calculated fields, so I don't think I can pin point which specific records needs to be updated.