Is there any way to find MIME type mismatch files in ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 01:37 PM
Hi ,
In ServiceNow is there any way to find MIME type mismatch files from sys_attachment table by scripting?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 08:59 PM
Hi Sumanth,
You can run this script in background script.
var attach = new GlideRecord('sys_attachment');
attach.groupBy('table_sys_id');
attach.query();
while(attach.next()){//use `while` if dealing with multiple attachments
if(attach.getValue('file_name').indexOf('pdf') != -1){//meaning if you can find a file with pdf extension
gs.print("File Name-- " +attach.file_name+" Table Name-- "+attach.table_name+" Table SysID-- "+attach.table_sys_id);
}
else {
gs.print("No file exists with pdf extension")};
}
If the response is useful, mark the answer correct and helpful.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 11:27 PM
Hi Sumanth,
You can find complete list of MIME type in the link mentioned below.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
The attachments allowed into servicenow are determined by the system property - glide.attachment.extensions - if this property is blank, that means all types of attachments are allowed in the system.
In sys_attachment we have a field as content_type which store the mime type of the attachment. Now you will have to make a comparison of Content type with the valid mime type with the link mentioned above. For ease purpose you can upload the valid mime type in a custom table to compare by the script in the tool itself.
Hope this helps.
Regards
Ujjawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2019 12:10 PM
You might be able to by querying every attachment, then grabbing that attachment, then attaching it to a dummy ticket.
Then to figure out all of the mismatches I found this KB Article in SN Hi KB0657692 that helped me figure out an issue I was having.
FYI, this is a list of all the MIME types, I'm not sure what subset that SN Supports, my guess is that it changes over time.