Issue
Symptoms
Unable to encrypt attachments using a bulk encryption script from documentation (https://docs.servicenow.com/csh?topicname=c_EncryptionSupport.html&version=latest).
The script throws an error stating:
org.mozilla.javascript.EcmaError: Cannot find function changeEncryptionContext in object [object GlideSysAttachment]
Release
All
Cause
The cause may be that the execution of the script is being done in the same scope as the table containing the attachment
Resolution
The execution of the script needs to be done in the global scope either as a background script, UI Action or Business rule.
The encryption context and associated sys_user_role can be in either global scope or in the scope of the table, but the execution of the script needs to be in global scope.