Getting an error when trying to insert into sys_user

Chris Schuh
Giga Contributor

Hi Everyone,

I'm running into an error I've never seen before. I'm trying to insert a new record into the sys_user table via a script in a workflow.

Example Script:

var grUserCreate = new GlideRecord('sys_user');
grUserCreate.initialize();
grUserCreate.setValue('user_name', 'CHRISTEST');
grUserCreate.insert();

 

So, when I run the above script in a workflow's Run Script, I get the error below. When I run it as a background script, it works.

Note: The sys_user table doesn't have any mandatory fields (which we are currently looking into why). Most records are imported via an LDAP sync run overnight. I'm working on a process where someone can create an account in the middle of the day, on demand, for situations when they cannot wait overnight for the account to automatically generate.

Any help would be appreciated.

Thanks!

 

Error Message from the Log:

FAILED TRYING TO EXECUTE ON CONNECTION glide.23 (connpid=290891): INSERT INTO perf_metric_probe_sensor () VALUES() /* CLIENTINSTANCENAME005, gs:glide.scheduler.worker.2, tx:28749a0adbab3f00d082323b7c9619e9 */
Syntax Error or Access Rule Violation detected by database (Table 'CLIENTINSTANCENAME_1.perf_metric_probe_sensor' doesn't exist)
: java.sql.SQLSyntaxErrorException: Table 'CLIENTINSTANCENAME_1.perf_metric_probe_sensor' doesn't exist: org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:138)
org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106)
org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:274)
org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:302)
org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:393)
sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.glide.db.StatementWrapper.invoke(StatementWrapper.java:40)
com.sun.proxy.$Proxy12.execute(Unknown Source)
com.glide.db.DBI.executeStatement0(DBI.java:1102)
com.glide.db.DBI.executeStatement(DBI.java:1058)
com.glide.db.DBI.executeStatement(DBI.java:1011)
com.glide.db.DBAction.executeAsResultSet(DBAction.java:284)
com.glide.db.DBCompositeAction.executeAsResultSet(DBCompositeAction.java:178)
com.glide.db.DBCompositeAction.executeChunk(DBCompositeAction.java:138)
com.glide.db.DBCompositeAction.executeAsResultSet0(DBCompositeAction.java:100)
com.glide.db.DBAction.executeAndReturnTable(DBAction.java:247)
com.glide.db.DBAction.executeNormal(DBAction.java:236)
com.glide.db.DBAction.executeAndReturnException(DBAction.java:190)
com.glide.script.GlideRecordITable.insert(GlideRecordITable.java:144)
com.glide.script.GlideRecord.insert(GlideRecord.java:4848)
com.glide.script.GlideRecord.insert(GlideRecord.java:4765)
com.snc.discovery.perf.metrics.DiscoveryPerformanceMetricsCollector.updateOrInsertProbeAndSensorIndividualMetric(DiscoveryPerformanceMetricsCollector.java:104)
com.snc.discovery.SensorProcessor.logPerformanceMetrics(SensorProcessor.java:1053)
com.snc.discovery.SensorProcessor.processSinglePage(SensorProcessor.java:401)
com.snc.discovery.SensorProcessor.process(SensorProcessor.java:194)
sun.reflect.GeneratedMethodAccessor1536.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.NativeJavaMethod.call(NativeJavaMethod.java:292)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2585)
org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
org.mozilla.javascript.gen.sys_trigger_bdb95e3fdb573300d082323b7c961943_2694._c_script_0(sys_trigger.bdb95e3fdb573300d082323b7c961943:2)
org.mozilla.javascript.gen.sys_trigger_bdb95e3fdb573300d082323b7c961943_2694.call(sys_trigger.bdb95e3fdb573300d082323b7c961943)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3429)
org.mozilla.javascript.gen.sys_trigger_bdb95e3fdb573300d082323b7c961943_2694.call(sys_trigger.bdb95e3fdb573300d082323b7c961943)
org.mozilla.javascript.gen.sys_trigger_bdb95e3fdb573300d082323b7c961943_2694.exec(sys_trigger.bdb95e3fdb573300d082323b7c961943)
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.Evaluator.evaluatePossiblePrefixedString(Evaluator.java:205)
com.glide.job.RunScriptJob.evaluateScript(RunScriptJob.java:163)
com.glide.job.RunScriptJob.execute(RunScriptJob.java:84)
com.glide.schedule.JobExecutor.lambda$executeJob$306(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$304(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)

1 ACCEPTED SOLUTION

Chris Schuh
Giga Contributor

Hi Ankur,

 

We did some more investigation and found out it was some issue within the workflow related to the Query AD action. If we put the script before the Query AD action, then the script worked. If we put it after, then it didn't work. We're still investigating with ServiceNow, but we aren't working on it right now as it turned out to not be a show-stopper.

Thanks!

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chris,

Does this happen everytime or sometimes?

Did you try giving any other value?

Also did you check any before insert business rule on that table

Regards

Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Chris Schuh
Giga Contributor

Hi Ankur,

 

We did some more investigation and found out it was some issue within the workflow related to the Query AD action. If we put the script before the Query AD action, then the script worked. If we put it after, then it didn't work. We're still investigating with ServiceNow, but we aren't working on it right now as it turned out to not be a show-stopper.

Thanks!