Update Bulk Records
Import
·
Aug 12, 2022
·
article
Following are two bulk update scripts that can be reused.
If record bulk is bigger than 5000
var gr = new GlideRecord('table_name');
gr.setLimit(100); //will update 100 records at a time
gr.addEncodedQuery('ADD QUERY'); // Add query
gr.query();
while(gr.next())
{
gr.short_description = gr.short_description+' :Closed By a Script';
/*
SET OTHER PARAMETERS HERE
*/
gr.setWorkflow(false); //Will not fire BR & email notifications
gr.update();
}
If you need it with a rollback option (Recommended for bulks less than 5000)
var gr = new GlideRecord("table_name");
gr.addEncodedQuery('ADD QUERY');
/*SET PARAMETERS HERE
i.e : gr.setValue('state', 5);
*/
gr.setWorkflow(false); //Will not fire BR & email notifications
gr.autoSysFields(false); // Do not update sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on
gr.updateMultiple();
View original source
https://www.servicenow.com/community/developer-articles/update-bulk-records/ta-p/2298701