- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 02:42 AM
Hi ,
Can someone help how to achieve to restrict .msg files getting added or attached to HR cases
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 03:10 AM
On attachement table create a before insert business rule to check for table name and attachment extension and there you can deny the .msg file type.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 03:10 AM - edited 08-12-2024 03:19 AM
Hi @haripriya5 ,
go through this community KB article, might be helpful : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0718013
You can also follow a scripting approach to check the filetype in attachment table, below is the explanation and steps:
To check the type of attachment on a ServiceNow record using a script, you can query the sys_attachment table, which stores information about all attachments in the system. You can then inspect the content_type field, which indicates the MIME type of the attachment (e.g., application/pdf for PDF files, image/png for PNG images).
Here’s a sample script you can use in a Script Include or Business Rule(recommended).
// Replace 'your_table' with the actual table name and 'record_sys_id' with the sys_id of the record you're checking.
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_name', 'your_table');
attachment.addQuery('table_sys_id', 'record_sys_id');
attachment.query();
while (attachment.next()) {
var fileName = attachment.file_name.toString();
var contentType = attachment.content_type.toString();
gs.info('File Name: ' + fileName);
gs.info('Content Type: ' + contentType);
// now you can perform any action based on the returned value..
}
Thanks and regards
HRISHABH KUMAR
Mark this helpful and Accept solution if my response turns helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 03:10 AM
On attachement table create a before insert business rule to check for table name and attachment extension and there you can deny the .msg file type.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....