gliderecord force update

brown9394
Tera Expert

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! 

1 ACCEPTED SOLUTION

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Brown,

By any chance are you executing this script in some scope because setForceUpdate is not allowed in scoped application

Can you check by adding log statements.

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

This is in global. Is there a better way to try this instead of using a background script? 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

Looking at this option of using a fix script, is this only a good option for scoped applications? I do not have a scoped app.