Decrypting masked variable in Flow Designer

Colin6
Tera Contributor

I'm attempting to access the decrypted value of a masked variable in a flow designer flow. The "getDecryptedValue()" method returns an empty string and using the decrypt method of a GlideDecrypter returns the ciphertext. The flow itself is running in a user context, and the account I'm using explicitly has the "catalog_view_masked" role, so I should have access to the plaintext. Am I missing something here?

3 REPLIES 3

PriyaRanji
Tera Guru

Hello Colin,

Could you please try using below line of code:

new GlideEncrypter().decrypt(PASSENCRYPTEDVALUE);

Please let me know if it works.

Thanks,

Priyanka R

Scott_Groth_BAH
Tera Contributor

Check out the linked support article.  It almost worked for me.  In my case I was using a "Get Catalog Variables" action.  The problem is the outputs are all strings.

I was able to do a GlideRecord request for the RITM.  At that point, you can use the getDecryptedValue() method to get the plain text version of the variable.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0681163

 

Example:

var gr = new GlideRecord('sc_req_item');

gr.get('<sys_id>');

var plain_text_var = gr.variables.masked_variable.getDecryptedValue();

 

Was Really helpful, thank you!!
For anyone looking for solution use this code in your script in flow designer,

var gr = new GlideRecord('sc_req_item');
if(gr.get(fd_data.trigger.request_item.sys_id)){
    var pwd = gr.variables.u_gw_password.getDecryptedValue();
return pwd;
}