Error while importing data to an encrypted field via Schedule JobIssue When importing data into an encryption field via Scheduled Job, it fails generating an error in logs Error while creating cipher for encryption context.: no thrown error and you see below stack trace: java.lang.NullPointerException: java.lang.NullPointerException: com.glide.encryption.PlatformEncrypterDecrypter.encrypt(PlatformEncrypterDecrypter.java:63)com.glide.encryption.PlatformEncrypterDecrypter.getEncryptedValue(PlatformEncrypterDecrypter.java:39)com.glide.element.decorator.GEPlatformEncryptedValueDecorator.decorateSetDisplayValue(GEPlatformEncryptedValueDecorator.java:85)com.glide.glideobject.GlideDateTime.getStorageValue(GlideDateTime.java:1652)com.glide.script.glide_elements.GlideElementGlideObject.getStorageValue(GlideElementGlideObject.java:107)com.glide.script.GlideRecord.setFields0(GlideRecord.java:6157)com.glide.script.GlideRecord.setFields(GlideRecord.java:6146)com.glide.script.GlideRecord.insert(GlideRecord.java:4839)com.glide.script.GlideRecord.insert(GlideRecord.java:4765)com.glide.script.GlideRecord.jsFunction_insert(GlideRecord.java:5262)sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:670)org.mozilla.javascript.FunctionObject.call(FunctionObject.java:614)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)org.mozilla.javascript.gen.sys_script_include_4657f46ddbb7f740c4aa755a8c9619da_script_21805._c_anonymous_2(sys_script_include.4657f46ddbb7f740c4aa755a8c9619da.script:139)org.mozilla.javascript.gen.sys_script_include_4657f46ddbb7f740c4aa755a8c9619da_script_21805.call(sys_script_include.4657f46ddbb7f740c4aa755a8c9619da.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524._c_anonymous_4(sys_script_include.89ec090adbc26340ee403ebd7c961907.script:72)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524.call(sys_script_include.89ec090adbc26340ee403ebd7c961907.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524._c_anonymous_3(sys_script_include.89ec090adbc26340ee403ebd7c961907.script:60)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524.call(sys_script_include.89ec090adbc26340ee403ebd7c961907.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524._c_anonymous_2(sys_script_include.89ec090adbc26340ee403ebd7c961907.script:33)org.mozilla.javascript.gen.sys_script_include_89ec090adbc26340ee403ebd7c961907_script_20524.call(sys_script_include.89ec090adbc26340ee403ebd7c961907.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)org.mozilla.javascript.gen.sys_script_3f5cc9c6dbc26340ee403ebd7c9619f0_script_16300._c_executeRule_1(sys_script.3f5cc9c6dbc26340ee403ebd7c9619f0.script:3)org.mozilla.javascript.gen.sys_script_3f5cc9c6dbc26340ee403ebd7c9619f0_script_16300.call(sys_script.3f5cc9c6dbc26340ee403ebd7c9619f0.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)org.mozilla.javascript.gen.sys_script_3f5cc9c6dbc26340ee403ebd7c9619f0_script_16300._c_script_0(sys_script.3f5cc9c6dbc26340ee403ebd7c9619f0.script:1)org.mozilla.javascript.gen.sys_script_3f5cc9c6dbc26340ee403ebd7c9619f0_script_16300.call(sys_script.3f5cc9c6dbc26340ee403ebd7c9619f0.script)org.mozilla.javascript.gen.sys_script_3f5cc9c6dbc26340ee403ebd7c9619f0_script_16300.exec(sys_script.3f5cc9c6dbc26340ee403ebd7c9619f0.script)com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:279)com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:118)com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:82)com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:309)com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:214)com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:201)com.glide.script.BusinessRule.runScript(BusinessRule.java:409)com.glide.script.BusinessRule.runSyncBusinessRule(BusinessRule.java:293)com.glide.script.BusinessRule.runBusinessRule(BusinessRule.java:204)com.glide.script.BusinessRule.run(BusinessRule.java:180)com.glide.script.GlideRecordBusinessRules.run(GlideRecordBusinessRules.java:95)com.glide.script.GlideRecord.runScripts(GlideRecord.java:1356)com.glide.script.GlideRecord.runScriptsAndEngines(GlideRecord.java:1290)com.glide.script.GlideRecord.postChange(GlideRecord.java:4964)com.glide.script.GlideRecord.postUpdate(GlideRecord.java:4932)com.glide.script.GlideRecord.updateWithoutResettingOperation(GlideRecord.java:4515)com.glide.script.GlideRecord.update(GlideRecord.java:4415)com.glide.script.GlideRecord.jsFunction_update(GlideRecord.java:4222)sun.reflect.GeneratedMethodAccessor282.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:670)org.mozilla.javascript.FunctionObject.call(FunctionObject.java:614)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)org.mozilla.javascript.gen.sys_script_include_f9445f6d4f9a9200ffe30f5e9310c73d_script_556._c_anonymous_4(sys_script_include.f9445f6d4f9a9200ffe30f5e9310c73d.script:430)org.mozilla.javascript.gen.sys_script_include_f9445f6d4f9a9200ffe30f5e9310c73d_script_556.call(sys_script_include.f9445f6d4f9a9200ffe30f5e9310c73d.script)org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2651)org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)org.mozilla.javascript.gen._refname__16298._c_script_0(:1)org.mozilla.javascript.gen._refname__16298.call()org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3429)org.mozilla.javascript.gen._refname__16298.call()org.mozilla.javascript.gen._refname__16298.exec()com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:279)com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:118)com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:82)com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:73)com.glide.script.Evaluator.evaluateString(Evaluator.java:91)com.snc.automation.ScriptJob.execute(ScriptJob.java:43)com.glide.schedule.JobExecutor.lambda$executeJob$275(JobExecutor.java:108)com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:111)com.glide.schedule.JobExecutor.execute(JobExecutor.java:95)com.glide.schedule.GlideScheduleWorker.executeJob(GlideScheduleWorker.java:236)com.glide.schedule.GlideScheduleWorker.lambda$process$363(GlideScheduleWorker.java:165)com.glide.worker.TransactionalWorkerThread.executeInTransaction(TransactionalWorkerThread.java:35)com.glide.schedule.GlideScheduleWorker.process(GlideScheduleWorker.java:165)com.glide.schedule.GlideScheduleWorker.run(GlideScheduleWorker.java:75)ReleaseAll releases wherein Edge Encryption is usedCauseScheduled job run without the user session, meaning it does not have access to user roles and therefore user contexts.ResolutionThis is an expected behavior. Scheduled job run without the user session, meaning it does not have access to user roles and therefore user contexts. That is by design, and even if the script is set to "Run as", the context is not granted for security reasons. Encryption contexts don't work with impersonation, so things like async business rules, inbound email, and scheduled jobs won't be able to access the key. Hence the "Attempt to get cipher for encryption context '' without authorization" error Reference Encryption script: https://docs.servicenow.com/csh?topicname=c_EncryptionSupport.html&version=latest https://docs.servicenow.com/csh?topicname=c_EncryptionRuleActions.html&version=latest Some community posts maybe help: https://www.linkedin.com/pulse/servicenow-encryption-method-naveen-amudalapelli/ https://community.servicenow.com/community?id=community_question&sys_id=ea760325db1cdbc01dcaf3231f9619e1&view_source=searchResult https://community.servicenow.com/community?id=community_question&sys_id=b16c07a5db9cdbc01dcaf3231f961940 https://community.servicenow.com/community?id=community_question&sys_id=2fa64765db1cdbc01dcaf3231f9619d5&view_source=searchResult