Script not working

Originally asked by ben friedman on 08 December 2021 (original question)


I wrote this script based on examples, but its not working and im getting an error.

when i tried to set a constant value to the the โ€œavoโ€ field, it was working fine.

def leftToRightUrgency = [
// left Assignee ---> right Assignee
โ€œื“ื—ื•ืคื”โ€ : โ€œEmegencyโ€,
โ€œื’ื‘ื•ื”ื”โ€ : โ€œHighโ€,
โ€œืจื’ื™ืœื”โ€ : โ€œMediumโ€,
โ€œื ืžื•ื›ื”โ€ : โ€œLowโ€
]

def urgency = leftToRightUrgency[โ€œIL ZDโ€.issue.ืขื“ื™ืคื•ืช?.value] ?: โ€œHighโ€

on[โ€œโ€โ€œavoโ€โ€œโ€].issue.customFields.urgency.value = urgency

the error message doesnt say anything specific.

please assist.


Answer by Francis Martens (Exalate) on 08 December 2021

Can you provide the details of the error. It also seems that the encoding of the customField name can result in problems

Can you change the name into the custom field id?

Let us know


Comments:

ben friedman commented on 08 December 2021

the error is not specific. it says:

Check the documentation for more details.

is the ID the identifier of the custom field?

if so, should it be

[โ€œIL ZDโ€.issue.360005568420?.value]?:โ€œHighโ€

ben friedman commented on 08 December 2021

Francis Martens (Exalate)

the error is not specific. it says:

Check the documentation for more details.

is the ID the identifier of the custom field?

if so, should it be

[โ€œIL ZDโ€.issue.360005568420?.value]?:โ€œHighโ€

Francis Martens (Exalate) commented on 08 December 2021

What is the stack trace - it is revealing a lot.

Can you give it a try and see if it help
also a debug.error statement can provide more information like

debug.error("The customfield is ${...}")

Where โ€ฆ is the value you would like to show.

ben friedman commented on 08 December 2021

im not sure where to look for the debug trace.

stack trace

com.exalate.domain.exception.editor.ScriptEditorException: com.exalate.admin.editor.errors.mappings.script at com.exalate.replication.services.replication.mapping.MappingService$$anonfun$1.applyOrElse(MappingService.scala:294) at com.exalate.replication.services.replication.mapping.MappingService$$anonfun$1.applyOrElse(MappingService.scala:276) at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:38) at scala.util.Failure.recoverWith(Try.scala:236) at com.exalate.replication.services.replication.mapping.MappingService.executeInScriptRule(MappingService.scala:276) at com.exalate.replication.services.replication.mapping.MappingService.$anonfun$receive$8(MappingService.scala:181) at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307) at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64) at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56) at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85) at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: com.exalate.api.exception.script.ScriptException: startup failed: Script55.groovy: 22: unexpected token: 360005568420 @ line 22, column 48. tToRightUrgency[โ€œIL ZDโ€.issue.3600055684 ^ 1 error at com.exalate.error.services.ScriptExceptionCategoryService.categorizeProcessorAndIssueTrackerExceptionsIntoScriptExceptions(ScriptExceptionCategoryService.scala:42) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:57) at com.exalate.replication.services.replication.mapping.MappingService.$anonfun$executeInScriptRule$1(MappingService.scala:272) at scala.util.Try$.apply(Try.scala:213) at com.exalate.replication.services.replication.mapping.MappingService.executeInScriptRule(MappingService.scala:269) โ€ฆ 16 more Caused by: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script55.groovy: 22: unexpected token: 360005568420 @ line 22, column 48. tToRightUrgency[โ€œIL ZDโ€.issue.3600055684 ^ 1 error at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:158) at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at com.exalate.processor.ExalateProcessor.execute(ExalateProcessor.java:98) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:55) โ€ฆ 19 more Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script55.groovy: 22: unexpected token: 360005568420 @ line 22, column 48. tToRightUrgency[โ€œIL ZDโ€.issue.3600055684 ^ 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311) at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:151) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:121) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:133) at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:325) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:224) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:192) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:226) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:201) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:965) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:642) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:618) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:595) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:401) at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89) at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:341) at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:338) at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:336) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:320) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:262) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:331) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153) โ€ฆ 22 more