How to do encryption an attachment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 10:13 PM
Hi ,
I have an requirement in which when user attach a form to any of a record like incident form it should automatically gets encrypted without click on encrypt on check box
Step i did till now
created a encryption context , add that to a specific role and also created a onAfter business rule on sys_attachment table
below is the code :-
var contextGR = new GlideRecord('sys_encryption_context');
contextGR.addQuery('name', 'Business Service Encryption');
contextGR.query();
if (!contextGR.next()) {
gs.log("[ERROR] No encryption context found");
}
var encryptionID = contextGR.getUniqueValue();
gs.info("i am BR encryptionID-->"+encryptionID);
if (encryptionID != "") {
var sysAttachment = new GlideSysAttachment();
sysAttachment.changeEncryptionContext(current.table_name, current.table_sys_id, current.sys_id,encryptionID '');
}
And when i checked the logs its showing me below error:-
org.mozilla.javascript.EcmaError: Cannot find function changeEncryptionContext in object [object GlideSysAttachment].
Caused by error in sys_script.8992451737191740ef0afa7b34990ed0.script at line 26
and this business rule is not working as expected.
can anyone help in this..
thanks in advance.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2018 10:49 PM
Hello,
I think changeEncryptionContext() function is not present in GlideSysAttchament API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2018 01:19 AM
but in doc and community i found this so i am trying to use the same ...
but by seeing the logs i found that so is there any alternative method which you used..?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2021 12:29 AM
Try running the script in Global application instead of scoped application
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748935