- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 11:04 AM
Hi all,
I m using GlideDigest to caclulate MD5hash in my scoped application.. i m in Istanbul release. Here is the code which i m using to calculate MD5Hash.. It generates different value for MD5Hash for my file. Please help me to understand what i m doing wrong over here.
var attachmentSysid='';
var ga=new GlideRecord('sys_attachment');
ga.addQuery('table_sys_id',current.sys_id);
ga.query();
while(ga.next()){
attachmentSysid=ga.sys_id;
}
var inputStream = new GlideSysAttachment().getContentStream(attachmentSysid);
var digest = new GlideDigest();
var test=digest.getMD5Base64FromInputStream(inputStream);
gs.addInfoMessage(test);
This is the link i have referred
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=c_GlideDigestScopedAPI
And earlier i tried with GlideCheckSum but since it needs to be whitelisted in order for it to be used and also it will work only in scoped application, i happened to go with this approach.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 10:36 AM
Instead of getMD5Base64FromInputStream i used getMD5HexFromInputStream
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 10:42 AM
Great kailashthiyagarajan . Can you mark my answer correct if it worked for you?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2019 01:12 PM
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 based on the hash, the attachment is not moved to the target record, but remains on the sys_email record.