Custom table - variable formatter - changes not saved

kristenankeny
Tera Guru

Attempting a new thread for this question. We needed to extend the sc_req_item table, which is done and most everything is working as needed. However, we're having issues with the variables not saving changes. The formatter is set up properly and shows the variables for the current required item (custom table name) and their appropriate values. When changes are made from the required item and saved, when the required item refreshes the changes are not reflected/are never saved.

1 ACCEPTED SOLUTION

kristenankeny
Tera Guru

After speaking with ServiceNow, we approached this solution differently. We kept the records on the sc_req_item table, instead of extending it. Then we added a field called "partitions" that has two values, one of which is default (so showing whatever view they have access to) and position_bundle, which triggers a view rule that forces them into the PositionBundle view. On the new record types, we set partition to "position_bundle" so that the view rules run.


View solution in original post

11 REPLIES 11

I did find that I wasn't creating a new entry in sc_item_option when creating the new sc_item_option_mtom. I made this adjustment to my script. Unfortunately, I'm still not able to save any changes to the variables.


kristenankeny
Tera Guru

I tried a different approach and instead of copying the RITMs to my new table, I decided to just move them (update the parent, request, and sys_class_name). It moved the record without any issue, but yet again, when I attempt updates to the variables from within the variable formatter, it does not save.


Further information: We were getting an error in the log about null table value. With this update, that error disappeared, but now I have a new error:



FAILED TRYING TO EXECUTE ON CONNECTION 26: INSERT INTO ts_c_11_7 (`document_number`, `word`, `positions`, `total_weight`) VALUES (91197, 5697, 'qg==', 1), (91197, 3266, 'CBkKsw==', 11), (91197, 1154, 'oQ==', 1), (91197, 4163, 'gg==', 1), (91197, 15750, 'tQ==', 1), (91197, 7495, 'kA==', 1), (91197, 4682, 'hQ==', 1), (91197, 3595, 'sQ==', 1), (91197, 3598, 'rA==', 1), (91197, 6798, 'uA==', 1), (91197, 3600, 'rg==', 1), (91197, 1169, 'gw==', 1), (91197, 7890, 'sA==', 1), (91197, 1237, 'jg==', 1), (91197, 4821, 'qA==', 1), (91197, 54553, 'ow==', 1), (91197, 7068, 'hA==', 1), (91197, 59550, 'gJY=', 2), (91197, 54558, 'pA==', 1), (91197, 3489, 'mw==', 1), (91197, 59554, 'CAcy', 50), (91197, 59555, 'CAgy', 50), (91197, 59556, 'CAky', 50), (91197, 54631, 'pQ==', 1), (91197, 16871, 'ug==', 1), (91197, 54634, 'pg==', 1), (91197, 3114, 'vA==', 1), (91197, 2091, 'pw==', 1), (91197, 4335, 'uw==', 1), (91197, 5488, 'CBgK', 10), (91197, 3634, 'nA==', 1), (91197, 1146, 'iw==', 1), (91197, 1147, 'oA==', 1), (91197, 1148, 'jA==', 1), (91197, 3132, 'tg==', 1), (91197, 3965, 'kpSe', 3) /* dev18067001, gs:glide.scheduler.worker.7, tx:3c1a6b214f83320043b401f18110c721 */


Unique Key violation detected by database (Duplicate entry '3266-91197' for key 'PRIMARY')


: com.glide.db.GlideSQLException: FAILED TRYING TO EXECUTE ON CONNECTION 26: INSERT INTO ts_c_11_7 (`document_number`, `word`, `positions`, `total_weight`) VALUES (91197, 5697, 'qg==', 1), (91197, 3266, 'CBkKsw==', 11), (91197, 1154, 'oQ==', 1), (91197, 4163, 'gg==', 1), (91197, 15750, 'tQ==', 1), (91197, 7495, 'kA==', 1), (91197, 4682, 'hQ==', 1), (91197, 3595, 'sQ==', 1), (91197, 3598, 'rA==', 1), (91197, 6798, 'uA==', 1), (91197, 3600, 'rg==', 1), (91197, 1169, 'gw==', 1), (91197, 7890, 'sA==', 1), (91197, 1237, 'jg==', 1), (91197, 4821, 'qA==', 1), (91197, 54553, 'ow==', 1), (91197, 7068, 'hA==', 1), (91197, 59550, 'gJY=', 2), (91197, 54558, 'pA==', 1), (91197, 3489, 'mw==', 1), (91197, 59554, 'CAcy', 50), (91197, 59555, 'CAgy', 50), (91197, 59556, 'CAky', 50), (91197, 54631, 'pQ==', 1), (91197, 16871, 'ug==', 1), (91197, 54634, 'pg==', 1), (91197, 3114, 'vA==', 1), (91197, 2091, 'pw==', 1), (91197, 4335, 'uw==', 1), (91197, 5488, 'CBgK', 10), (91197, 3634, 'nA==', 1), (91197, 1146, 'iw==', 1), (91197, 1147, 'oA==', 1), (91197, 1148, 'jA==', 1), (91197, 3132, 'tg==', 1), (91197, 3965, 'kpSe', 3) /* dev18067001, gs:glide.scheduler.worker.7, tx:3c1a6b214f83320043b401f18110c721 */


Unique Key violation detected by database (Duplicate entry '3266-91197' for key 'PRIMARY')


: com.glide.db.DBIError.wrapAndThrow(DBIError.java:119)


com.glide.db.DBIError.handleException(DBIError.java:72)


com.glide.db.DBI.executeStatement(DBI.java:898)


com.glide.db.DBI.executeStatement(DBI.java:854)


com.glide.db.DBI.executeStatement(DBI.java:846)


com.glide.db.BatchStatement.executeOneByOne(BatchStatement.java:92)


com.glide.db.StatementBatcher.commitOneByOne(StatementBatcher.java:421)


com.glide.db.StatementBatcher.commit(StatementBatcher.java:263)


com.glide.db.StatementBatcher.close(StatementBatcher.java:197)


com.glide.ts.indexer.TSWriter.close(TSWriter.java:137)


com.glide.ts.event.TSActionHandler.flushWriters(TSActionHandler.java:50)


com.glide.ts.event.TSActionHandler.flush(TSActionHandler.java:42)


com.glide.policy.EventProcessor.flush(EventProcessor.java:235)


com.glide.policy.EventManager.processEvents(EventManager.java:295)


com.glide.policy.EventManager._process(EventManager.java:165)


com.glide.policy.EventManager.process(EventManager.java:147)


sun.reflect.GeneratedMethodAccessor327.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:2574)


org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)


org.mozilla.javascript.gen._refname__183._c_script_0(<refname>:1)


org.mozilla.javascript.gen._refname__183.call(<refname>)


org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)


org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3432)


org.mozilla.javascript.gen._refname__183.call(<refname>)


org.mozilla.javascript.gen._refname__183.exec(<refname>)


com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:259)


com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110)


com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76)


com.glide.script.ScriptEvaluator.evaluateStringWithPrefix(ScriptEvaluator.java:60)


com.glide.script.Evaluator.evaluatePossiblePrefixedString(Evaluator.java:202)


com.glide.job.RunScriptJob.evaluateScript(RunScriptJob.java:163)


com.glide.job.RunScriptJob.execute(RunScriptJob.java:86)


com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:103)


com.glide.schedule.JobExecutor.execute(JobExecutor.java:89)


com.glide.schedule.GlideScheduleWorker.executeJob(GlideScheduleWorker.java:219)


com.glide.schedule.GlideScheduleWorker.process(GlideScheduleWorker.java:157)


com.glide.schedule.GlideScheduleWorker.run(GlideScheduleWorker.java:67)



I assume this is because I moved the record and it thinks the sys_id is a duplicate? How might I resolve this? (Not sure how this would fix the issue I'm really trying to solve though: inability to save changes to the variable values from the custom table's variable formatter.


kristenankeny
Tera Guru

After speaking with ServiceNow, we approached this solution differently. We kept the records on the sc_req_item table, instead of extending it. Then we added a field called "partitions" that has two values, one of which is default (so showing whatever view they have access to) and position_bundle, which triggers a view rule that forces them into the PositionBundle view. On the new record types, we set partition to "position_bundle" so that the view rules run.


Hi Kristen,

Did they proivide any reason on why these changes are not saved  ? Incident also have this kind of formatter and the changes do get saved there.

Please let me know if you have any other details.

 

Thanks