- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2015 12:29 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2015 09:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2015 09:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2021 06:15 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2021 09:39 AM
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
Hopefully this helps others as well.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 07:54 AM
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