ServiceNow Things to Know 4: getBytes function
Did you know getBytes function in attachment script has some size limits?
getBytes function is used in attachments scripts to get base64 data. This function has a payload limit of 4MB which means attachments larger than 4MB cannot be transferred. Below scripts can be used as an alternative.
Script where getBytes function is used:
var sa = new GlideSysAttachment();
var binData = sa.getBytes(attachmentRecordObject);
var base64 = GlideStringUtil().base64Encode(binData); // Limit of 4MB
Alternative - Calling script from non-global scope:
var sa = new GlideSysAttachment();
sa.getContent(attachmentRecordObject);
var base64 = sa.getContentBase64(attachmentRecordObject);
Alternative - Calling script from global scope:
https://www.servicenow.com/community/developer-blog/servicenow-things-to-know-4-getbytes-function/ba-p/2753864