While loop is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 03:47 AM
Hello All,
I have below code in schedule job which is written on Demand.
It is working correctly but evertime when I execute it update only 1 record it should update all the record if condition matches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 04:36 AM
that's correct. but since you added try catch block even if error is thrown for a record the loop can still run.
try adding query to update only 1 record for which the difference condition matches
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 04:43 AM
Hello Ankur,
Yes tried that , by using sys_id where the diff is less then 864000 , it didn't update that record ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 04:44 AM
If we run the same script in background also it will not run the while loop , not sure where it is going wrong as our instance is domain separated, I have written this in IGBP domain only so that it is applicable for all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 04:49 AM
@Nisha B Can you please share the log entries as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 05:04 AM
Hello Arun,
I have just checked the error log as the code in try catch- I am getting below message
Error while recording sample: java.lang.NullPointerException: com.glide.db.stats.interaction.InteractionPattern.<init>(InteractionPattern.java:27)
com.glide.db.stats.interaction.InteractionSample.getPattern(InteractionSample.java:59)
com.glide.db.stats.VolatileMetricStatsListener.addToNursery(VolatileMetricStatsListener.java:117)
com.glide.db.stats.VolatileMetricStatsListener.observeSample(VolatileMetricStatsListener.java:92)
com.glide.db.stats.interaction.InteractionStats.record(InteractionStats.java:28)
com.glide.ux.metrics.stats.SlowInteractionsMonitoringService.submit(SlowInteractionsMonitoringService.java:23)
com.glide.ux.metrics.ClientMetricsService.addInteraction(ClientMetricsService.java:48)
com.glide.ux.metrics.ClientMetricsConfiguration.lambda$getWiring$1(ClientMetricsConfiguration.java:55)
com.glide.graphql.impl.extensions.schema.transformer.NamespacedResolverTransformer.lambda$transform$0(NamespacedResolverTransformer.java:27)
com.glide.graphql.fetchers.GraphQLTransactionCancelledFetcher.get(GraphQLTransactionCancelledFetcher.java:33)
graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation.lambda$instrumentDataFetcher$0(DataLoaderDispatcherInstrumentation.java:90)
graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation.lambda$instrumentDataFetcher$0(DataLoaderDispatcherInstrumentation.java:90)
graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:292)
graphql.execution.streaming.StreamingExecutionStrategy.fetchField(StreamingExecutionStrategy.java:39)
graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:222)
graphql.execution.ExecutionStrategy.resolveField(ExecutionStrategy.java:194)
graphql.execution.AsyncSerialExecutionStrategy.lambda$execute$1(AsyncSerialExecutionStrategy.java:46)
graphql.execution.Async.eachSequentiallyImpl(Async.java:80)
graphql.execution.Async.eachSequentially(Async.java:69)
graphql.execution.AsyncSerialExecutionStrategy.execute(AsyncSerialExecutionStrategy.java:41)
graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:774)
graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:469)
graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:418)
graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$1(ExecutionStrategy.java:224)
java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:223)
graphql.execution.ExecutionStrategy.resolveField(ExecutionStrategy.java:194)
graphql.execution.AsyncSerialExecutionStrategy.lambda$execute$1(AsyncSerialExecutionStrategy.java:46)
graphql.execution.Async.eachSequentiallyImpl(Async.java:80)
graphql.execution.Async.eachSequentially(Async.java:69)
graphql.execution.AsyncSerialExecutionStrategy.execute(AsyncSerialExecutionStrategy.java:41)
graphql.execution.ExecutionStrategy.completeValueForObject(ExecutionStrategy.java:774)
graphql.execution.ExecutionStrategy.completeValue(ExecutionStrategy.java:469)
graphql.execution.ExecutionStrategy.completeField(ExecutionStrategy.java:418)
graphql.execution.ExecutionStrategy.lambda$resolveFieldWithInfo$1(ExecutionStrategy.java:224)
java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:223)
graphql.execution.ExecutionStrategy.resolveField(ExecutionStrategy.java:194)
graphql.execution.AsyncSerialExecutionStrategy.lambda$execute$1(AsyncSerialExecutionStrategy.java:46)
graphql.execution.Async.eachSequentiallyImpl(Async.java:80)
graphql.execution.Async.eachSequentially(Async.java:69)
graphql.execution.AsyncSerialExecutionStrategy.execute(AsyncSerialExecutionStrategy.java:41)
graphql.execution.Execution.executeOperation(Execution.java:177)
graphql.execution.Execution.execute(Execution.java:121)
graphql.GraphQL.execute(GraphQL.java:697)
graphql.GraphQL.lambda$parseValidateAndExecute$12(GraphQL.java:616)
java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)
java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
graphql.GraphQL.parseValidateAndExecute(GraphQL.java:611)
graphql.GraphQL.executeAsync(GraphQL.java:578)
graphql.GraphQL.executeStreaming(GraphQL.java:487)
com.glide.graphql.impl.GraphQLEngine.executeOperation(GraphQLEngine.java:102)
com.glide.graphql.impl.streaming.GlideGraphQLStreamingOutput.handleRequest(GlideGraphQLStreamingOutput.java:59)
com.glide.graphql.impl.streaming.GlideGraphQLStreamingOutput.write(GlideGraphQLStreamingOutput.java:45)
com.glide.rest.serializer.impl.ResponseSerializerImpl.serializeStream(ResponseSerializerImpl.java:132)
com.glide.rest.handler.impl.ServiceResultHandlerImpl.serialize(ServiceResultHandlerImpl.java:128)
com.glide.rest.handler.impl.ServiceResultHandlerImpl.processServiceResultBody(ServiceResultHandlerImpl.java:96)
com.glide.rest.handler.impl.ServiceResultHandlerImpl.processServiceResult(ServiceResultHandlerImpl.java:40)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:340)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:625)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:277)
com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:184)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:172)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:51)
com.glide.sys.Transaction.run(Transaction.java:2501)
com.glide.ui.HTTPTransaction.run(HTTPTransaction.java:27)
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)