- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 10:10 AM
I am going to run a Fix script to rename all attachments file name (lakhs of records). I would like to know how long it takes approximately? any running limit for fix script?
Because I was trying to get the count of qualified records but that itself is taking more than 2 hours.
Please check my code and suggestions will be welcomed.
print("START");
var count = 0;
var sysAttInc = new GlideRecord('sys_attachment');
sysAttInc.addQuery('table_name','incident');
sysAttInc.query();
while(sysAttInc.next()){
var validInc = new GlideRecord('incident');
validInc.addEncodedQuery("assignment_group=c28d8a6d2beaaa406cb40e4319da1508^ORassignment_group=1c41dd4913f936005c9851522244b09d^ORassignment_group=02a925bcdd77480063a86cfcb6a2eef9^ORassignment_group=f3a98122e52ac5406cb4e93d6b1b4c7b^ORassignment_group=19e9b688875ca0848cb5ae076d434d33^ORassignment_group=eabf64d1ade4d1843e61c11c7bfcdd3c^ORassignment_group=6aea2e270fcc3e80d2de305be1050e2a^ORassignment_group=71ab8f83b834564053edcd6285ffb43e^ORassignment_group=e683e138dd77480063a86cfcb6a2ee9e^ORassignment_group=85d6b3c587b460408cb5ae076d434d58^ORassignment_group=e08b0f83b834564053edcd6285ffb49c^ORassignment_group=7de931f8871be800e2b5fc9e59434d9f^ORassignment_group=cf933d18a863f5003e6152c1f0bd8817^ORassignment_group=16cbcf83b834564053edcd6285ffb432^ORassignment_group=927337e213765680c06f7d322244b04c^sys_id=" + sysAttInc.table_sys_id);
validInc.query();
while(validInc.next()){
sysAttInc.file_name = validInc.number +'_'+ sysAttInc.file_name;
count ++;
}
//sysAttInc.u_comments = sysAttInc.file_name;
//sysAttInc.update();
}
gs.print("Total Records Renamed: " + count);
gs.print("END");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 11:34 AM
Hi,
I think you can't determine how long fix script will run ,for better option run your script in scheduled job.
Thanks,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 11:34 AM
Hi,
I think you can't determine how long fix script will run ,for better option run your script in scheduled job.
Thanks,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 06:48 PM
Hi,
I couldn't able to trace what is wrong with Fix script but schedule job worked perfect

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 11:43 AM
I don't think there is any time limit as such. But for long running records, you should select the option "Proceed in Background" so that there is no stopping of the script like closing the browser window.
Mark the comment as correct answer if this answers your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2019 01:59 PM
I know this isn't the answer to your original question, but looping through each item and adding to a counter just to get the count is not an efficient way of getting the count. Take a look at GlideAggregate if you want a more efficient way to at least get the count of qualifying records.
https://docs.servicenow.com/bundle/jakarta-application-development/page/script/glide-server-apis/concept/c_GlideAggregate.html