How to resolve the background scripts issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 06:59 AM - edited ‎02-19-2025 06:59 AM
Hi,
I have 5 lakhs+ records in sc_req_item table so we have used background script to delete the records and close the background scripts tab but still it is running i want to stop the backgroung script because based on the below script it is deleting 50 records instead of 10000 records.
Can anyone please help on this, It will be useful.
var batchSize = 10000; // Process 10,000 records at a time
var totalDeleted = 0;
var gr;
do {
gr = new GlideRecord('sc_req_item');
gr.setLimit(batchSize);
gr.query();
var count = 0;
while (gr.next()) {
gr.deleteRecord();
count++;
}
totalDeleted += count;
gs.sleep(1000); // Prevent system overload
} while (count > 0);
gs.print("Deleted " + totalDeleted + " records from sc_req_item.");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 07:09 AM
@mania on the background script page you can write cancelt_my_transaction.
Add https://dev99999.service-now.com/cancel_my_transaction.
Mark my response as helpful if it helped resolve your doubt.
Thanks,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 07:15 AM
you can cancel the transaction
Go to Active Transactions then kill your background script, it will stop.
Best is to use fix script and let that run in background
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2025 11:27 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2025 11:47 PM
Instead of using background script . you can "Delete jobs" and if you want that deleted records back you can also reverte back in "Delete jobs".