On Change Client Script Not Working

Aqil
Tera Contributor

I have a OnChange client script running on a catalog item, that runs when the value of a "u_subcategory" variable changes. And, I just want to get the value of "u_subcategory" variable. I'm using the g_form.getValue() method but it's not working, then I used g_scratchpad, but that's too not working. I have checked the ServiceNow logs table, and it is giving the below error:

Exception while executing request: stream has already been operated upon or closed: com.glide.rest.util.RESTRuntimeException: Exception while executing request: stream has already been operated upon or closed: com.glide.rest.handler.impl.ServiceHandlerImpl.handleInvocationTargetException(ServiceHandlerImpl.java:76)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:49)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:346)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:733)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:291)
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:2645)
com.glide.ui.HTTPTransaction.run(HTTPTransaction.java:30)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)

7 REPLIES 7

SwapnilKumar
Tera Contributor

Hi

 

i would suggest you to put logs at multiple places and test step by step execution and i could see your syntax of getxmlwait is incorrect which might be causing the lssue

 

 please try and let us know if got any specific error.

thanks

swapnil

ShrutiG57423582
Tera Contributor

Hello Aqil,

 

I am facing same error. upon click on Submit button, It shows only submitting......and record dosen't submit. I checked in logs and I found this error same as you.

 

Exception while executing request: stream has already been operated upon or closed: com.glide.rest.util.RESTRuntimeException: Exception while executing request: stream has already been operated upon or closed: com.glide.rest.handler.impl.ServiceHandlerImpl.handleInvocationTargetException(ServiceHandlerImpl.java:76)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:49)
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)

Did you find any solution?

 

Thanks.

 

vishwajeet5550
Mega Guru

If u_subcategory is a reference field, g_form.getReference is the correct method to use. It will allow you to retrieve the full record and access its fields. g_form.getValue  will only give you the Sys ID of the referenced record, so if you need other details (like the name or other fields), you must use getReference