Encryption of Field Cause Script Include to Fail
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have a script include that imports employees from our HR System. The issue is the script now fails when it executes the encryption code.
//Encrypted fields
employee.u_last_four_ssn.setDisplayValue(this._getLastFour(d.ZY_CT_KEY_FLD));
employee.u_last_four_ssn.setContextID(encryptionID);
employee.u_dob.setDisplayValue(dob);
employee.u_dob.setContextID(encryptionID);
employee.u_phone.setDisplayValue(this._formatPhoneNumber(d.PHONE));
employee.u_phone.setContextID(encryptionID);
//employee.u_nid.setDisplayValue(d.ZY_CT_KEY_FLD);
employee.u_nid.setContextID(encryptionID);
//Update
employee.update();
else where in the code to get the encryption ID:
_getEncryptionID: function(encryptionName) {
var contextGR = new GlideRecord("sys_encryption_context");
contextGR.addQuery("name", encryptionName);
contextGR.query();
if (!contextGR.next()) {
gs.info("*********** No such encryption context " + encryptionName);
return "";
Any ideas as to why it is failing. I'm not too familiar with encryption 😞
}
return contextGR.getUniqueValue();
},
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
if your script runs as system user then field level encryption is bypassed.
You can create a module access policy for your script include or business rule so that system ignores the encryption context for fields
Step-by-Step Guide to Configuring an Encryption Module in ServiceNow
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
