How to do encryption an attachment?

msmbittu
Kilo Contributor

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.

3 REPLIES 3

Bhagya Lakshmi
Mega Guru

Hello,

I think changeEncryptionContext() function is not present in GlideSysAttchament API.

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..?

Aakash Shah4
Tera Guru

Try running the script in Global application instead of scoped application 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748935