Is there a way to determine the hash value of an incoming attachment to SN? In general, trying to avoid attaching signature images to created incidents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2015 10:45 AM
Is there a way to determine the hash value of an incoming attachment to SN? In general, trying to avoid attaching signature images to created incidents. The signature images come in with a random name of 'image001.png' through 'image011.png' depending on how many you have.
I've considered trying to compare sys_attachment_doc records, but the attachments names are not always the same so if 'image001' came in I would need to compare it to 11 different attachments to be sure it's not a match on them and am concerned that would be a performance issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2015 10:59 AM
Just a heads up, as of Fuji, the GlideSysAttachment.getBytes() method has a 5MB file limit. Raising the limit to higher than 5MB endangers the heap memory of the JVM. For files whose sys_attachment.byte_size are greater than 5MB the code returns an empty byte array (new byte[0]). The fundamental design concern is that code should not be designed to put arbitrarily large objects into static data structures. Perhaps a solution can be designed that is based on holding only one chunk of attachment data at a time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2015 11:29 AM
Fortunately signature images tend to be in the sub-megabyte range, so a limit can be put in the condition so the code doesn't bother to run for larger images.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 03:22 AM
Thanks for sharing this,
I don't know how to calculate hash values of images & how to store that value in a table field u_code.
Kindly share the update set, that would be more helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2023 08:37 AM
Just curious but if you are using getbytes and then generating the hash based on that, won't you get the same hash for files with the same value returned from getbytes?
I wonder if anyone know how ServiceNow generates the hash for new attachments? It would be nice if we could leverage that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2019 01:07 PM
This is a long-ago post, but I'm replying in case someone happens to be looking for information.
As of New York, a SHA256 is calculated and put into sys_attachment.hash field and this is something you can use.
See "Attachments are assigned unique identifiers" in the New York release notes.
Additionally if an email arrives with an attachment (image or otherwise),its hash is compared to other attachments on the target record that have a hash. If the identical content already exists on the target record, the attachment is not moved to the target record, but remains on the sys_email record.