Encrypt Password (2 Way Encrypted) field value

naveenreddy0871
Tera Contributor

Screenshot 2026-07-17 165358.pngHi team,

 

How can we encrypt a value in a Password (2-Way Encrypted) field?

 

The field resides in a table that belongs to the XXX application scope, and the encryption is required during the execution of a Transform Map associated with a specific data source that exists in the Global application scope.

 

I attempted to create a cross-scope privilege to allow access between the applications. However, the system does not allow me to select Global as the source scope while configuring the privilege.

 

Could you please advise on the recommended approach for encrypting the field value in this scenario and handling the cross-scope access requirements?

 

 
 

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@naveenreddy0871 

what's your exact business requirement?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Tanushree Maiti
Tera Patron

Hi @naveenreddy0871 

 

Refer:Password2 encryption with the Key Management Framework (KMF) 

This example script shows you how to encrypt my@Password in the password2 column of table 'table_xyz'.
var  gr =  new GlideRecord(‘table_xyz’);
gr.pwd2column_name.setDisplayValue('my@Password');
 
gr.insert();
Important:
You can’t use the setValue() API for the Password2 field.

This example script shows you how to decrypt the same field to retrieve the value:

var  gr =  new GlideRecord(‘table_xyz’);
gr.query();
gr.next();
var ge=gr.getElement('pwd2column_name');
var ged1 = ge.getDecryptedValue(); 
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Tanushree Maiti
Tera Patron

Hi @naveenreddy0871 

 

Refer: Password2 encryption with the Key Management Framework (KMF) 

This example script shows you how to encrypt my@Password in the password2 column of table 'table_xyz'.
var  gr =  new GlideRecord(‘table_xyz’);
gr.pwd2column_name.setDisplayValue('my@Password');
 
gr.insert();
Important:
You can’t use the setValue() API for the Password2 field.

This example script shows you how to decrypt the same field to retrieve the value:

var  gr =  new GlideRecord(‘table_xyz’);
gr.query();
gr.next();
var ge=gr.getElement('pwd2column_name');
var ged1 = ge.getDecryptedValue(); 
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti