Decrypt a Password 2 Column Field

syedasimali
Kilo Expert

Would like to store passwords using Password (2 way Encrypted) in a custom table.

Is it possible to have a button to decrypt the password field of a particular record. That button should only be visible to ServiceDesk Team.

Any help would be much appreciated

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Syed,



Below thread should answer your question.


Re: Decrypting a value to set as password not working


Thanks Pardeep for getting back to me.



I only want users with a specific role can decrypt the password column. and I don't want it to be displayed permanently for privileged users in plain text. rather it should only reveal with they press a button or something similar.



I do not know how/where to define that in the below script. Sorry I am new to ServiceNow scripting.




  1. (function executeRule(current, previous /*null when async*/) {  
  2.   // Add your code here  
  3.   var Encrypter = new GlideEncrypter();  
  4.   var decrypted = Encrypter.decrypt(current.u_encrypted_password);  
  5.  
  6.   var gu = new GlideRecord('incident');  
  7.   gu.initialize();  
  8.   gu.u_encrypted_password.setDisplayValue(decrypted + '');  
  9.   gu.insert();  
  10.  
  11. })(current, previous);  

Hi Syed,



You can show or hide UI action button to user has per the roles.


I.e in condition field of the UI action add gs.hasRole("admin") //Replace admin with the role you want to check.


UI Actions - ServiceNow Wiki



Refer this link and adjust above code in UI action.


http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/


I hope you might figured out by now.



You script is perfect for playing through encryption and you just need to figure the access to the option. Let me know if you need help.