diff --git a/Server-Side Components/Background Scripts/Cleanup Old Attachments/Delete attachments older than 720 days.js b/Server-Side Components/Background Scripts/Cleanup Old Attachments/Delete attachments older than 720 days.js new file mode 100644 index 0000000000..c6067a9619 --- /dev/null +++ b/Server-Side Components/Background Scripts/Cleanup Old Attachments/Delete attachments older than 720 days.js @@ -0,0 +1,9 @@ +var attachment = new GlideRecord('sys_attachment'); +attachment.addQuery('sys_created_on', '<=', gs.daysAgo(720)); +attachment.query(); +var count = 0; +while (attachment.next()) { + attachment.deleteRecord(); + count++; +} +gs.print('Deleted ' + count + ' attachments older than 720 days.'); diff --git a/Server-Side Components/Background Scripts/Cleanup Old Attachments/Readme.md b/Server-Side Components/Background Scripts/Cleanup Old Attachments/Readme.md new file mode 100644 index 0000000000..b2e7b8be5c --- /dev/null +++ b/Server-Side Components/Background Scripts/Cleanup Old Attachments/Readme.md @@ -0,0 +1,3 @@ +This script helps manage system storage by removing attachments older than 720 days. +It prevents unnecessary disk usage and keeps the ServiceNow instance optimized. +Supports system performance and operational efficiency through regular housekeeping.