Is there a way to make the encryption of attachments automatic, rather than a checkbox visible to the user?

Joseph_Wheeler
ServiceNow Employee
ServiceNow Employee

I have a customer who does not want to let users forget to encrypt attachments.   Is there a way to make the encryption of attachments, using a single context, mandatory for all users?

1 ACCEPTED SOLUTION

brian_quinn
ServiceNow Employee
ServiceNow Employee

Joseph,



Similar to the post below linked below, you can force encryption to be enabled with a fixed encryption context on attachments by going to "System UI -> UI Pages" and finding the record for "attachment".   Modify the "Client script" field by adding the following the very beginning (modify the sys_id to the sys_id of the encryption context you want to force):



/**


* Enable encryption and disable checkbox


*/


forceEncryption();


function forceEncryption() {


      var ck_encrypt = gel('encrypt_checkbox');


      ck_encrypt.value = 'on';


      ck_encrypt.checked = true;


  gel('encrypt_checkbox').disabled = 'disabled';


  encryptionSelected('1b6e7167b9b202004e8230b4f32ea02e');


}



You will also have to add a forceEncryption() call as the last line of the refreshAttachments() function.  



Re: Attachement Pop-up - Encryption



2 things to keep in mind with this though... A user who does not have permission to the hard coded encryption context will not be able to select any other context and the file will be uploaded unencrypted.   This modification will also mean that any future updates ServiceNow makes to this UI Page will be skipped.



Thanks


Brian


View solution in original post

5 REPLIES 5

brian_quinn
ServiceNow Employee
ServiceNow Employee

Joseph,



Similar to the post below linked below, you can force encryption to be enabled with a fixed encryption context on attachments by going to "System UI -> UI Pages" and finding the record for "attachment".   Modify the "Client script" field by adding the following the very beginning (modify the sys_id to the sys_id of the encryption context you want to force):



/**


* Enable encryption and disable checkbox


*/


forceEncryption();


function forceEncryption() {


      var ck_encrypt = gel('encrypt_checkbox');


      ck_encrypt.value = 'on';


      ck_encrypt.checked = true;


  gel('encrypt_checkbox').disabled = 'disabled';


  encryptionSelected('1b6e7167b9b202004e8230b4f32ea02e');


}



You will also have to add a forceEncryption() call as the last line of the refreshAttachments() function.  



Re: Attachement Pop-up - Encryption



2 things to keep in mind with this though... A user who does not have permission to the hard coded encryption context will not be able to select any other context and the file will be uploaded unencrypted.   This modification will also mean that any future updates ServiceNow makes to this UI Page will be skipped.



Thanks


Brian


Hi Brian,

I used the code as mentioned, the encrypt option is read only but attached file is still not encrypted. PFB screenshot how i used it and let me know if i did something wrong.

I used this at the of refreshattachments function.

Please help me with this i'll be highly grateful

Thanks,

Sarabjeet

Hi Sarabjeet,

I was having the same issue as you and was able to fix this by replacing the "encryptionSelected" line with "sysparm_encryption_context" like below. For me this is placed at the very top of the client script, instead of inside the refreshAttachments() function.

/**
* Enable encryption and disable checkbox
*/
forceEncryption();
function forceEncryption() {
       var ck_encrypt = gel('encrypt_checkbox');
       ck_encrypt.value = 'on';
       ck_encrypt.checked = true;
   gel('encrypt_checkbox').disabled = 'disabled';
   $('sysparm_encryption_context').value = "6a63b3a01b7bf0108e4d54662a4bcb80";
}

Then on the last line of the refreshAttachments() function add forceEncryption() like below

find_real_file.png

Hopefully this helps others as well.

Thanks,

David

How to automatically encrypt attachments - Support and Troubleshooting (servicenow.com)

For those running into issues using this, it may be due to the encryptionSelected function. I found the above knowledge document that has replaced that line with  'gel('sysparm_encryption_context').value = "..." '

Using that updated line got this working for me. Hopefully this saves someone some time