Unique Key Violation When Closing Catalog Task

ZachOnNow
Tera Guru

Hello everyone, every time I close a catalog task I created in flow designer, I get a Unique Key Violation error. It always happens when I'm looping in which my use case requires, I've tried Do the following until flow logic, Try catch with go back to flow logic and then trying without try block and just go back to step but every time I get the same error. The only thing that worked was in the loop, instead of using the Create Catalog Task action, I used the new Fire Event action and my script action that responded to the event created a catalog task but I couldn't get my MRVS to be in the Variable Editor in the Catalog Task because I'm not sure if that is possible or not in a script, so I need the Create Catalog Task action because you can set the Variable Editor in it. Here's some screenshots:

Screenshot 2024-02-17 205344.pngScreenshot 2024-02-17 205608.png

4 REPLIES 4

Community Alums
Not applicable

Hi @ZachOnNow ,

You will need to check for any underlying existing Business rule (specially with current.update), which could be the potential cause of this Error.

To find the right business rule "debug business rule detail" you can run :

SandeepDutta_0-1708263374177.png

 

Also, learn to debug business rules : https://docs.servicenow.com/bundle/washingtondc-application-development/page/script/business-rules/r...

 

Okay thank you I will try that! Will the business rule be for the Catalog Task [sc_task] table since it's happening when I'm closing a catalog task or will it be for the Requested Item [sc_req_item] table? Or will running that command automatically find it for me? I haven't used it before. Thanks Again!

I'm still having trouble figuring out the problem, this is the error message if anyone can deduce it: FAILED TRYING TO EXECUTE ON CONNECTION glide.2 (connpid=326474): INSERT INTO sys_flow_value (`parent_loops`,`sys_id`,`execution_sequence`,`sys_created_on`,`context`,`name`,`length`,`value`,`sys_created_by`) VALUES('g1[1]','21a5c388cbe8821022bb3dd50bb8782e',21,'2024-02-19 15:22:36','30a58388fbe882106305ae2479a0f074','s5.runtime_info',1371,'{\"@valueType\":\"namedType\",\"value\":{\"@typeName\":\"HashMap\",\"integration_metadata\":{\"retryInfoMetadata\":null,\"retryableOpExecMode\":null,\"hostname\":\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\",\"inputPayloadSize\":350,\"outputPayloadSize\":465,\"requestMetadata\":\"{\\\"Full URL\\\":\\\"https://872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io/valid\\\",\\\"Outbound Record ID\\\":\\\"UNKNOWN\\\",\\\"Added Headers\\\":\\\"{\\\\\\\"X-SNC-INTEGRATION-SOURCE\\\\\\\":\\\\\\\"bdf2b1bd1b66f11c9377eb9b2d4bcb22\\\\\\\",\\\\\\\"User-Agent\\\\\\\":\\\\\\\"ServiceNow/1.0\\\\\\\",\\\\\\\"Host\\\\\\\":\\\\\\\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\\\\\\\",\\\\\\\"Content-Length\\\\\\\":\\\\\\\"189\\\\\\\"}\\\"}\",\"runtimeMID\":null,\"connection\":null,\"credential\":\"\"},\"async_response_runtime_info_key\":\"{\\\"cursorLabel\\\":\\\"DEFAULT\\\",\\\"waitToken\\\":\\\"6jA8etqNO1mEnktMavGcUnFCpZRDDatM\\\",\\\"message\\\":\\\"http_operation/async_response\\\"}\",\"runtime_env\":{\"runtimeEnvironment\":\"GLIDE\",\"midServerName\":null},\"integration_info\":{\"connectionInfo\":{\"dataMap\":{\"mid_selection\":\"auto_select\",\"use_mid\":\"false\",\"capabilities\":\"18409d8007482000dada43c0d1021e8f\",\"application\":\"35aa573fd7802200bdbaee5b5e610375\",\"mid_server\":\"\",\"mid_cluster\":\"\",\"host\":\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\"},\"credentialSysId\":null,\"extendedAttributes\":{},\"extendedAttributeTypes\":{}},\"paenvironment\":{\"midNameList\":null,\"env\":\"GLIDE\",\"clustered\":false}}},\"storageType\":\"VALUE\"}','system') /* dev214543001, gs:5794830847E88210BCC99889316D436C, tx:b3958b8047e88210bcc99889316d4333 */
Unique Key violation detected by database ((conn=326474) Duplicate entry '30a58388fbe882106305ae2479a0f074-21-s5.runtime_info-g1[1]' for key 'context')
: com.glide.db.GlideSQLException: FAILED TRYING TO EXECUTE ON CONNECTION glide.2 (connpid=326474): INSERT INTO sys_flow_value (`parent_loops`,`sys_id`,`execution_sequence`,`sys_created_on`,`context`,`name`,`length`,`value`,`sys_created_by`) VALUES('g1[1]','21a5c388cbe8821022bb3dd50bb8782e',21,'2024-02-19 15:22:36','30a58388fbe882106305ae2479a0f074','s5.runtime_info',1371,'{\"@valueType\":\"namedType\",\"value\":{\"@typeName\":\"HashMap\",\"integration_metadata\":{\"retryInfoMetadata\":null,\"retryableOpExecMode\":null,\"hostname\":\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\",\"inputPayloadSize\":350,\"outputPayloadSize\":465,\"requestMetadata\":\"{\\\"Full URL\\\":\\\"https://872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io/valid\\\",\\\"Outbound Record ID\\\":\\\"UNKNOWN\\\",\\\"Added Headers\\\":\\\"{\\\\\\\"X-SNC-INTEGRATION-SOURCE\\\\\\\":\\\\\\\"bdf2b1bd1b66f11c9377eb9b2d4bcb22\\\\\\\",\\\\\\\"User-Agent\\\\\\\":\\\\\\\"ServiceNow/1.0\\\\\\\",\\\\\\\"Host\\\\\\\":\\\\\\\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\\\\\\\",\\\\\\\"Content-Length\\\\\\\":\\\\\\\"189\\\\\\\"}\\\"}\",\"runtimeMID\":null,\"connection\":null,\"credential\":\"\"},\"async_response_runtime_info_key\":\"{\\\"cursorLabel\\\":\\\"DEFAULT\\\",\\\"waitToken\\\":\\\"6jA8etqNO1mEnktMavGcUnFCpZRDDatM\\\",\\\"message\\\":\\\"http_operation/async_response\\\"}\",\"runtime_env\":{\"runtimeEnvironment\":\"GLIDE\",\"midServerName\":null},\"integration_info\":{\"connectionInfo\":{\"dataMap\":{\"mid_selection\":\"auto_select\",\"use_mid\":\"false\",\"capabilities\":\"18409d8007482000dada43c0d1021e8f\",\"application\":\"35aa573fd7802200bdbaee5b5e610375\",\"mid_server\":\"\",\"mid_cluster\":\"\",\"host\":\"872e037f-9b21-470b-bdba-5598ff52aa72.mock.pstmn.io\"},\"credentialSysId\":null,\"extendedAttributes\":{},\"extendedAttributeTypes\":{}},\"paenvironment\":{\"midNameList\":null,\"env\":\"GLIDE\",\"clustered\":false}}},\"storageType\":\"VALUE\"}','system') /* dev214543001, gs:5794830847E88210BCC99889316D436C, tx:b3958b8047e88210bcc99889316d4333 */
Unique Key violation detected by database ((conn=326474) Duplicate entry '30a58388fbe882106305ae2479a0f074-21-s5.runtime_info-g1[1]' for key 'context')
: com.glide.db.DBIError.wrapAndThrow(DBIError.java:171)
com.glide.db.DBIError.handleException(DBIError.java:104)
com.glide.db.DBI.executeStatement(DBI.java:1457)
com.glide.db.DBI.executeStatement(DBI.java:1347)
com.glide.db.BatchStatement.executeOneByOne(BatchStatement.java:147)
com.glide.db.StatementBatcher.commitOneByOne(StatementBatcher.java:800)
com.glide.db.StatementBatcher.commit(StatementBatcher.java:472)
com.glide.db.StatementBatcher.flush(StatementBatcher.java:380)
com.glide.db.StatementBatcher.close(StatementBatcher.java:397)
com.snc.process_flow.engine.v2.serialization.OutputRepository.flush(OutputRepository.java:433)
com.snc.process_flow.v2.repo.RuntimeValueCache.flush(RuntimeValueCache.java:212)
com.snc.process_flow.v2.repo.PersistedRuntimeValues.flush(PersistedRuntimeValues.java:140)
com.snc.process_flow.v2.exec.EngineV2.run(EngineV2.java:126)
com.snc.process_flow.v2.exec.EngineRunner.lambda$run$0(EngineRunner.java:28)
com.snc.process_flow.v2.exec.enviroment.execution.ExecutionScopeRunner.run(ExecutionScopeRunner.java:37)
com.snc.process_flow.v2.exec.EngineRunner.run(EngineRunner.java:28)
com.snc.process_flow.engine.EngineV2Adapter.run(EngineV2Adapter.java:253)
com.snc.process_flow.engine.EngineV2Adapter.resume(EngineV2Adapter.java:349)
com.snc.process_flow.engine.ProcessAutomation.run(ProcessAutomation.java:101)
com.snc.process_flow.engine.GlideProcessAutomation.runSync(GlideProcessAutomation.java:218)
com.snc.process_flow.engine.GlideProcessAutomation.runWithDomain(GlideProcessAutomation.java:378)
com.snc.process_flow.engine.GlideProcessAutomation.lambda$runAsUserSync$1(GlideProcessAutomation.java:343)
com.snc.process_flow.engine.PFSessionClone.run(PFSessionClone.java:71)
com.snc.process_flow.engine.GlidePFSession.runPlanAsUserSession(GlidePFSession.java:42)
com.snc.process_flow.engine.GlideProcessAutomation.runAsUserSync(GlideProcessAutomation.java:341)
com.snc.process_flow.engine.GlideProcessAutomation.messageFlow(GlideProcessAutomation.java:429)
com.snc.process_flow.engine.GlideProcessAutomation._start(GlideProcessAutomation.java:711)
com.snc.process_flow.engine.GlideProcessAutomation$StartBuilder.start(GlideProcessAutomation.java:1723)
com.glide.flow.providers.FlowGlideProvider.testSubFlow(FlowGlideProvider.java:1850)
com.glide.flow.providers.FlowGlideProvider.testFlow(FlowGlideProvider.java:1816)
com.glide.flow_design.rest.FlowService.testRunFlow(FlowService.java:824)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:568)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:44)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:345)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:762)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:313)
com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:187)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:175)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:58)
com.glide.sys.Transaction.run(Transaction.java:2734)
com.glide.ui.HTTPTransaction.run(HTTPTransaction.java:35)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base/java.lang.Thread.run(Thread.java:840)

@ZachOnNow Did you ever find a solution for this? I'm getting the exact same error with a unique key violation for key 'context'.

 

Edit:
Just wanted to give people who find this post with the same issue an update. I resolved it by taking part of my flow into a subflow. After I did that, I'm not longer getting this error.