Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 02:08 AM
you can use after insert BR on incident table and then query sys_attachment and know the size and accordingly update the work notes
Business Rule: After Insert on incident
Script:
(function executeRule(current, previous /*null when async*/) {
var grAttachment = new GlideRecord('sys_attachment');
grAttachment.addQuery('table_name', 'incident');
grAttachment.addQuery('table_sys_id', current.sys_id);
grAttachment.addQuery('size_bytes', '>', 3145728); // 3 MB in bytes
grAttachment.query();
var largeAttFiles = [];
while (grAttachment.next()) {
largeAttFiles.push(grAttachment.file_name + ' ('+(grAttachment.size_bytes/1048576).toFixed(2)+' MB)');
}
if (largeAttFiles.length > 0) {
current.work_notes = 'The following attachments uploaded are larger than 3MB:\n' + largeAttFiles.join('\n');
current.setWorkflow(false);
current.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader