
Sandaru1
Tera Expert
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎08-12-2022 05:33 AM
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();
- 4,401 Views
Comments
WP2
Kilo Guru
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
‎11-15-2022
11:39 PM
How do you bulk update field on SCTask with the value of a field from RITM. E.g I have over 5000 SCTask records that have blank company field however, I want to copy over the data from the company field on the RITM.

Martin Ivanov
Giga Sage
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
‎11-15-2022
11:56 PM
var grScTask = new GlideRecord('sc_task');
grScTask.addNullQuery('company');
grScTask.query();
while (grScTask.next()){
grScTask.setValue('company', grScTask.request_item.company);
grScTask.update();
}
Please mark Correct and Helpful. Thanks!
WP2
Kilo Guru
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
‎11-17-2022
07:28 PM
Thank you @Martin Ivanov It worked!
Fabricio4
Mega Sage
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
‎06-21-2024
05:20 PM
This is such a wonderful tip. Thanks!