How to encrypt and decrypt attachments using CLE and encryption modulesSummary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The purpose of this article it to show how to encrypt and decrypt attachments via script where encryption modules are being used Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } San Diego and newer NOTE: Encryption Modules have been available since San Diego but you may not have been migrated to encryption modules till Vancouver. Please validate on your instances if you are using Module Encryption to see if you can leverage this information Instructions<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The following api is available to to encrypt attachments that are not encrypted or to change the module encryption from one to another: changeCryptoModule(table_name, table_record_sys_id, current_attached_sys_id, encryption_modoule_sys_id) To decrypt the attachment the following function can be used: disableEncryption(table_name, table_record_sys_id, current_attached_sys_id); Example code: var table_name = "incident"; //table name of source recordvar table_sys_id = "6604a12e87984e103eadfdd4dabb3536"; //Record sys_id from source tablevar current_attach_sys_id = "8a59467087640a103eadfdd4dabb3520"; //attachment sys_id attached to source recordvar encryption_mod_sys_id = "af229ad2c375b510800491477d013135"; //Encryption Module sys_id used to encrypt attachment var sys_attachment = new GlideSysAttachment(); //Encrypt attachment sys_attachment.changeCryptoModule(table_name, table_sys_id, current_attach_sys_id, encryption_mod_sys_id); //Decrypt attachment sys_attachment.disableEncryption(table_name, table_sys_id, current_attach_sys_id); NOTE:When testing with the above code comment out the decryption section to confirm that the record is getting encrypted. To confirm the record is getting decrypted, comment the encryption script and uncomment the decryption script Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } NOTE: If you require to run this script as system, this will require Column Level Encryption Enterprise. This will enable to option to create a module access policy for system which will grant access to the encryption module. For more information about Column Level Encryption Enterprise, please see the following docs: https://docs.servicenow.com/bundle/washingtondc-platform-security/page/administer/now-platform-encryption/concept/now-platform-encryption.html