- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 01:53 AM
Hii,
i have a scenario where only PDF files should only get attach to the incident form. How can i achieve this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2022 11:21 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 10:14 PM
Hello Sir now i want to restrict docs,png,jpg type attachment and allow pdf and other type how can i get this requirement
(function executeRule(current, previous /*null when async*/) {
// Check if the attachment is related to the incident table
if (current.table_name == 'incident') {
var allowedFileTypes = ['application/pdf', 'application/octet-stream']; // Add more allowed types as needed
var fileType = current.getValue('content_type');
gs.info('Attachment File Type: ' + fileType); // Log the file type for debugging
// Check if the file type is not allowed
if (!allowedFileTypes.includes(fileType)) {
gs.addErrorMessage('Attachment of type ' + fileType + ' is not allowed for incidents.');
current.setAbortAction(true);
}
}
})(current, previous);
using this script all type giving error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2025 01:57 AM
Thank you so much! Your solution worked perfectly. I really appreciate you sharing it — this saved me a lot of time.