
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2017 12:19 PM
I am trying to push data from variables in a Catalog Item into an encrypted field on the sc_req_item table without any luck. Here is the script I am currently using:
current.approval = 'approved';
// Sets the field encryption contextID
current.u_encrypted_info.setContextID("82a9095d4f8fd600b04176601310c70a"); // sys_encryption_context.sys_id
// Sets the field information
current.u_encrypted_info += "MRN Name: " + current.variable_pool.mrn_name;
current.u_encrypted_info += "\nDOB: " + current.variable_pool.dob;
current.u_encrypted_info += "\nMRN: " + current.variable_pool.mrn;
The encrypted field on the form is not showing at all once the workflow processes, I am assuming because there is an error in the code. I am using the sys_id from the sys_encryption_context table.
Am I missing something? Do I need to run a query on the sys_encryption_context table first and use the GlideRecord return?
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2017 12:31 PM
I believe you need to use the setDisplayValue() function to set the value of your u_encrypted_info field because setting the actual value will store it unencrypted.
var encryptedInfo = "MRN Name: " + current.variable_pool.mrn_name;
encryptedInfo += "\nDOB: " + current.variable_pool.dob;
encryptedInfo += "\nMRN: " + current.variable_pool.mrn;
current.u_encrypted_info.setDisplayValue(encryptedInfo);
current.u_encrypted_info.setContextID("82a9095d4f8fd600b04176601310c70a"); // sys_encryption_context.sys_id
See this example: Encryption Scripting - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2017 12:31 PM
I believe you need to use the setDisplayValue() function to set the value of your u_encrypted_info field because setting the actual value will store it unencrypted.
var encryptedInfo = "MRN Name: " + current.variable_pool.mrn_name;
encryptedInfo += "\nDOB: " + current.variable_pool.dob;
encryptedInfo += "\nMRN: " + current.variable_pool.mrn;
current.u_encrypted_info.setDisplayValue(encryptedInfo);
current.u_encrypted_info.setContextID("82a9095d4f8fd600b04176601310c70a"); // sys_encryption_context.sys_id
See this example: Encryption Scripting - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 06:58 AM
That worked! Thanks!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2017 05:31 PM