During Import Transformation: Encryption context error :attempting to parse the value: XXXXX using KMFEncryptedObject. Details: java.lang.NullPointerExceptionDescriptionDuring Import Transformation: Encryption context error :attempting to parse the value: XXXXX using KMFEncryptedObject. Details: java.lang.NullPointerException When trying to field map or transform script a value into an Encryption Context enabled column on the target table. Node logs will contain similar output: 2021-04-06 15:29:20 (635) worker.4 worker.4 txid=609b9aaa1b5f DEBUG: Error occured while attempting to parse the value: 2000-12-31 using KMFEncryptedObject. Details: java.lang.NullPointerException2021-04-06 15:29:20 (637) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** Attempt to get cipher for encryption context '34918a221b1fec10ac4475561a4bcbb7' without authorization2021-04-06 15:29:20 (637) worker.4 worker.4 txid=609b9aaa1b5f SEVERE *** ERROR *** Error while creating cipher to decrypt value2021-04-06 15:29:20 (638) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** javascript eval for GlideDate returned 2021-04-06 15:29:20 (640) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** Attempt to get cipher for encryption context '34918a221b1fec10ac4475561a4bcbb7' without authorization2021-04-06 15:29:20 (640) worker.4 worker.4 txid=609b9aaa1b5f SEVERE *** ERROR *** Error while creating cipher for encryption context.2021-04-06 15:29:20 (641) worker.4 worker.4 txid=609b9aaa1b5f Background message, type:error, message: Invalid attempt. Encrypted data could not be saved2021-04-06 15:29:20 (654) worker.4 worker.4 txid=609b9aaa1b5f sn_hr_core: JDL: 2000-12-312021-04-06 15:29:20 (657) worker.4 worker.4 txid=609b9aaa1b5f sn_hr_core: JDL: 98ee86ae1b1fec10ac4475561a4bcb262021-04-06 15:29:20 (657) worker.4 worker.4 txid=609b9aaa1b5f DEBUG: Error occured while attempting to parse the value: 2000-12-31 using KMFEncryptedObject. Details: java.lang.NullPointerException2021-04-06 15:29:20 (661) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** Attempt to get cipher for encryption context '34918a221b1fec10ac4475561a4bcbb7' without authorization2021-04-06 15:29:20 (661) worker.4 worker.4 txid=609b9aaa1b5f SEVERE *** ERROR *** Error while creating cipher for encryption context.2021-04-06 15:29:20 (662) worker.4 worker.4 txid=609b9aaa1b5f Background message, type:error, message: Invalid attempt. Encrypted data could not be saved2021-04-06 15:29:20 (738) worker.4 worker.4 txid=609b9aaa1b5f Completed: ProgressWorker in 0:00:00.282, next occurrence is null 2021-04-06 15:29:20 (614) worker.4 worker.4 txid=609b9aaa1b5f DEBUG: Error occured while attempting to parse the value: 2000-12-31 using KMFEncryptedObject. Details: java.lang.NullPointerException2021-04-06 15:29:20 (619) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** Attempt to get cipher for encryption context '34918a221b1fec10ac4475561a4bcbb7' without authorization2021-04-06 15:29:20 (619) worker.4 worker.4 txid=609b9aaa1b5f SEVERE *** ERROR *** Error while creating cipher for encryption context.2021-04-06 15:29:20 (620) worker.4 worker.4 txid=609b9aaa1b5f Background message, type:error, message: Invalid attempt. Encrypted data could not be savedSteps to Reproduce Steps to reproduce:(0) Make sure the "Encryption Support" plugin is active(1) Go into the "Human Resources: Core" application when creating everything in the subsequent steps below and when running the import with the encimport user which is the user that has the encryption context role applied(2) Create import set table "sn_hr_core_post_clone_hr_profile_v1" Extends table = Import Set Row:https://<instance>.service-now.com/sys_db_object.do?sys_id=3b984ee61b1fec10ac4475561a4bcbec&sysparm_record_target=sys_db_object&sysparm_record_row=1&sysparm_record_rows=5131&sysparm_record_list=sys_update_nameISNOTEMPTY%5EORDERBYDESCsys_created_on(3) Create Encryption Context "HR_SSN_DOB":https://<instance>.service-now.com/sys_encryption_context.do?sys_id=34918a221b1fec10ac4475561a4bcbb7&sysparm_record_target=sys_encryption_context&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=sys_idNOT+IN5c295d10939332009c8579b4f47ffba2%5EORDERBYname(4) Create Role "sn_hr_core.ssn_dob_encrypt" with encryption context "HR_SSN_DOB":https://<instance>.service-now.com/sys_user_role.do?sys_id=460382a21b1fec10ac4475561a4bcbea(5) Create a user like User ID encimport with role "sn_hr_core.ssn_dob_encrypt" (also gave admin and security_admin roles) for encryption context "HR_SSN_DOB" - pw = encimport:https://<instance>.service-now.com/sys_user.do?sys_id=832346a21b1fec10ac4475561a4bcb94&sysparm_record_target=sys_user&sysparm_record_row=1&sysparm_record_rows=636&sysparm_record_list=ORDERBYDESCsys_created_on(6) Create Encrypted Field Configurations on table columns sn_hr_core_profile.ssn and sn_hr_core_profile.date_of_birth using encryption context "HR_SSN_DOB":https://<instance>.service-now.com/nav_to.do?uri=%2Fsys_platform_encryption_configuration_list.do%3Fsysparm_query%3Dencryption_context%3D34918a221b1fec10ac4475561a4bcbb7%26sysparm_first_row%3D1%26sysparm_view%3Dcontext(7) Create Transform map "post_clone_hr_profile_tf_v4":https://<instance>.service-now.com/sys_transform_map.do?sysparm_nostack=true&sys_id=3e9a904fdbc2281019764b7c139619c9Source table = sn_hr_core_post_clone_hr_profile_v1Target table = sn_hr_core_profileAfter the import is run once create the one field mapping and make it the coalesce field:u_number to numberCreate the following OnAfter script:https://<instance>.service-now.com/sys_transform_script.do?sys_id=8bfb64321b3a24146acba9b6624bcb9f&sysparm_record_target=sys_transform_script&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=map%3D3e9a904fdbc2281019764b7c139619c9%5EORDERBYorder(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {// Add your code herevar gr = new GlideRecord('sn_hr_core_profile');gr.addQuery('sys_id', target.sys_id);gr.query();if (gr.next()) {gs.info("JDL: " + source.u_date_of_birth);gs.info("JDL: " + target.sys_id);gr.ssn = source.u_ssn;gr.date_of_birth = source.u_date_of_birth;gr.update();}})(source, map, log, target);(8) Disable "User is mandatory" data policy in sn_hr_core_profile table:https://<instance>.service-now.com/sys_data_policy2.do?sys_id=f65330019f22120047a2d126c42e70e4&sysparm_record_target=sys_data_policy2&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=model_table%3Dsn_hr_core_profile%5EORmodel_tableINsn_hr_core_profile(9) Be sure to be logged in as the encimport user when running the imports since this user has the encryption contexts - Go to the Load Data module and run the import:Import set table = Existing table: post_clone_hr_profile_v1 [sn_hr_core_clone_r_profile_v1]Source of the import = FileChoose file - select the attached file sn_hr_core_profile_parissit_new.csvSubmitRun Transform -> Selected map = post_clone_hr_profile_tf_v4TransformOnce this runs once you can go back and add the u_number to number Field map for the transform map in step (7)(10) When the import runs it will create three new sn_hr_core_profile records from the csv data, this is the list on the test system:https://<instance>.service-now.com/sn_hr_core_profile_list.do?sysparm_query=&sysparm_first_row=1&sysparm_view=You will notice that Date of birth and Social Security number are never written by the OnAfter script, the data is in the import set table, the log will show this error:2021-04-06 15:29:20 (614) worker.4 worker.4 txid=609b9aaa1b5f DEBUG: Error occured while attempting to parse the value: 2000-12-31 using KMFEncryptedObject. Details: java.lang.NullPointerException2021-04-06 15:29:20 (615) worker.0 worker.0 txid=e49bdaaa1b5f Spin waiting for mutex SMRecomputationLock to be freed2021-04-06 15:29:20 (619) worker.4 worker.4 txid=609b9aaa1b5f WARNING *** WARNING *** Attempt to get cipher for encryption context '34918a221b1fec10ac4475561a4bcbb7' without authorization2021-04-06 15:29:20 (619) worker.4 worker.4 txid=609b9aaa1b5f SEVERE *** ERROR *** Error while creating cipher for encryption context.2021-04-06 15:29:20 (620) worker.4 worker.4 txid=609b9aaa1b5f Background message, type:error, message: Invalid attempt. Encrypted data could not be savedWorkaroundWorkaround: Approach would be: 1) Import data (as plain text), i.e. without encryption contexts. 2) Transform and manipulate as desired 3) As a user w/ security_admin role, run mass encryption job on that imported data. We enhanced the design to support this use case, Rome release with the Platform Encryption pluginRelated Problem: PRB1489524