How to Update a field value in bulk of around 80 thousands records?

Taaha M
Tera Contributor

I am looking for a solution where I want to update a field value for around 80 thousand records. How to update it?

2 REPLIES 2

Vipul Sethi
Kilo Guru

Write a fix script to update the record and set the limit of records that you are going to update.

refer this for understanding  fix script https://docs.servicenow.com/en-US/bundle/tokyo-application-development/page/build/applications/conce...

 

Example script

var gr = new GlideRecord('Tablename');   
gr.setLimit(100); //This will update 100 records at a time, you can increase the limit but dont go overboard with the limit
gr.addEncodedQuery(active=true^fieldname!=NULL);   //You can add any query here which is specific to your scenario.
gr.query();   
while(gr.next())   
   {   
   gr.fieldname= 'test';   
   gr.setWorkflow(false); //Will not fire BR/email notifications   
   gr.update();   
   }   

 

SteveMac1
Mega Guru

You can speed things up by using 'updateMultiple' instead of looping. 

Check out Tim Woodruff's article on SN Pro Tips below for more info.

https://snprotips.com/blog/2016/12/20/pro-tip-use-updatemultiple-for-maximum-efficiency