Skip to content

Instantly share code, notes, and snippets.

@thisnameissoclever
Last active August 24, 2022 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thisnameissoclever/c242a267e8fddf1b81ff0c8eab3b6ade to your computer and use it in GitHub Desktop.
Save thisnameissoclever/c242a267e8fddf1b81ff0c8eab3b6ade to your computer and use it in GitHub Desktop.
Fallback method for calculating MD5 hashes for ServiceNow attachments. Requires HI ticket to access to the calculateMD5CheckSum() method of the GlideChecksum class from ServiceNow.
var grAttachment = new GlideRecord('sys_attachment'); //the table where attachment metadata is stored
grAttachment.get('0003ea666f015600623008efae3ee4f7'); //sys_id of a record in the sys_attachment table
var md5HashSum = calculateMD5Hash(grAttachment);
function calculateMD5Hash(attachmentGR) {
var attachmentInputStream = GlideSysAttachmentInputStream(attachmentGR.sys_id + '');
var chksum = (new GlideChecksum()).calculateMD5CheckSum(attachmentInputStream);
gs.print(chksum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment