Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to decrypt a field manually when Mass Decryption is not available in the instance - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to decrypt a field manually when Mass Decryption is not available in the instance
KB0743087

How to decrypt a field manually when Mass Decryption is not available in the instance


3088 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Description


This article explains how to decrypt a previously encrypted field manually when a Mass Decryption is not available in the instance.

Procedure


This procedure needs the admin user to create a new field in the table to copy the encrypted values. . Assuming the numbers of the records are unique, you can write a script to copy all the record numbers in the particular and encrypted field's display value(It will work only if you are logged in as a user with Encryption Context) to an EXCEL file. Once you do that, you can create a new string field for the table in the instance and copy the values to the new field using Import Sets (https://docs.servicenow.com/csh?topicname=import-sets-landing-page.html&version=latest?title=Import_Sets) 

Following is an example script that you can use to copy the field values to an Excel file. Please test and modify to your business requirements to copy and download the data. Please run and test the code properly preferably on an OOB instance before running this in your instances and seek help from your developers when you try the script. 

Sample Script

var output = "Number,Encrypted Field"; //header for csv file 
var table = "table_name"; 
var recordId = ""; //using for attachment file 
var gr = new GlideRecord(table); 
//gr.addEncodedQuery("sysID="); //Test if it works with a particular SysID 
gr.query(); 


var count = 0; 
while (gr.next()) { 
count++; 
output += "\n" + gr.number + "," + gr.ENCRYPTED_FIELD.getDisplayValue(); //Enter encrypted field name 
if (!recordId) { 
recordId = gr.sys_id; 
} 
} 

gs.print(recordId); 
writeAttachmentFile(output); 

function writeAttachmentFile(data) { 
var attachment = new Attachment(); 
var attachmentRec = attachment.write(table, recordId, "exportEncrypted.csv", "text/csv", data); 
} 

Once you run your script in the Scripts - Background, you can navigate to sys_attachment.list to download exportEncrypted.csv file. You can use import sets to Map and import the data to your instance(to your newly created String Field).

Applicable Versions


All available versions

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.