Decrypt a Password 2 Column Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 08:19 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 08:57 AM
Hi Syed,
Below thread should answer your question.
Re: Decrypting a value to set as password not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 12:47 PM
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.
- (function executeRule(current, previous /*null when async*/) {
- // Add your code here
- var Encrypter = new GlideEncrypter();
- var decrypted = Encrypter.decrypt(current.u_encrypted_password);
- var gu = new GlideRecord('incident');
- gu.initialize();
- gu.u_encrypted_password.setDisplayValue(decrypted + '');
- gu.insert();
- })(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 01:09 PM
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.
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 06:57 AM
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.