Change encryption context

abrahams
Kilo Sage

Would anyone know how to change Encryption context once it is set without using the encryption selector?

Out of the Box "Change Encryption" UI Action doesn't appear to work in Jakarta.  I've tried to get it to work but I am struggling a bit.  I was able to get rid of the errors written to the console.  The adjustments I made in attempt to make it work I thought would work but it doesn't appear to set User Preference and I'm not sure why.  Please let me know if you see anything I may have missed.  We don't use the OOB Social Security or Credit Card fields.

My Attempt ... I know it knows value because the value shows in the field message ... I don't see setPreference working:

UI Action:

Script:

var encryptionDialog;

function changePHIencryption() {
 encryptionDialog = new GlideDialogForm("Change Encryption Context",'ui_page');
 encryptionDialog.addParm("name", "dialog_choose_encryption"); // specifies the name of the UI Page to show
 encryptionDialog.render();
}

function encryptionSelected(newContext) {
 g_form.setValue("u_encryption_context", newContext);
 updateEncryptionChoice(newContext);
 encryptionDialog.destroy();
 //   g_form.save();
}

function encryptionCanceled() {
 encryptionDialog.destroy();
}

function updateEncryptionChoice(value) {
 rememberEncryption(value);
//    changeEncryptionSelect(value);
 var ename = '';
 // Get encryption context display name
 var egr = new GlideRecord('sys_encryption_context');
 egr.addQuery('sys_id',value);
 egr.query();
 if (egr.next()) {
  ename = egr.name;
 }
 g_form.hideFieldMsg('u_phi_information');
 g_form.showFieldMsg('u_phi_information','PHI information will be encrypted with ' + ename + ' context','info');
}

function rememberEncryption(value) {
 setPreference('u_encryption_context', value);
}

function changeEncryptionSelect(newContext) {
 parent.selectMenuItem(newContext, "gsft_encryption_select");
 // Following lines change the encryption context in the encryption selection box if visible
 var selectEncryptObj = parent.document.getElementById('gsft_encryption_select');
 // Select and default the encryption context option
 if (selectEncryptObj) {
  for(var i=0; i < selectEncryptObj.options.length; i++) {
   if (selectEncryptObj.options[i].value == newContext) {
    selectEncryptObj.selectedIndex = i;
   }
  }
 }
}

 

2 REPLIES 2

abrahams
Kilo Sage

I was able to figure this out.  I guess I should have given myself just a little more time to figure this out.  Thank you!

what was solution?