Attempting to get Jira Status put to a Jira Variable

Originally asked by David Oosting on 09 January 2020 (original question)


Wanting to get just the status of the Jira ticket put into a Zendesk Variable. With Zendesk, specific variable are given a number, and trying to get that variable assigned thru the incoming sync because the outgoing sync already sends it.
outgoing (Jira) -> replica.status = issue.status
Incoming(Zendesk) -> issue.customField.“360023300132”.value = nodeHelper.getOption(issue, 360023300132L , replica.status.value?.value)Source: Jira Server/Datacenter (old community)


Answer by David Oosting on 15 October 2020

This all has to do with status mapping in Jira. So using workflows, I had to create a workflow that matches the Zendesk workflow

Open → Open

Pending → Pending

On-hold → On hold

Solved → Solved

Closed → Closed

Once this was done, mapping was easily solved.


Answer by André Leroy-Beaulieu Castro on 13 January 2020

Hi David,

Basically there is a bug in our code which doesn’t let you assign a string to a custom field of type option, so the workaround would be to add this to your incoming script:

def opt = new com.exalate.basic.domain.hubobject.v1.BasicHubOption()
opt.value = replica.status.name
issue.customFields."Remote Status"?.value = opt

of course you can change “Remote Status” to the actual name of your custom field, you don’t need to access it with the ID like you were doing before, with the name works fine.

The code will be improved in the following days to make this simpler so you will be able to do:

issue.customFields."Remote Status"?.value = replica.status.name

but for now please use the workaround!

Let me know how this goes.

Thanks,

André


Answer by David Oosting on 09 January 2020

Actually,

I am now getting an error on

issue.customFields.“360023300132”.value = replica.status.name

this does not work either.


Comments:

André Leroy-Beaulieu Castro commented on 10 January 2020

That’s because the field is of type option, I was giving you the code for when the custom field was of type single-line text, try this out:

issue.customField."360023300132".value = nodeHelper.getOption(issue, 360023300132L , replica.status.name)

Thanks,

André

André Leroy-Beaulieu Castro commented on 10 January 2020

Sorry there was a typo:

issue.customFields."360023300132".value = nodeHelper.getOption(issue, 360023300132L , replica.status.name)
David Oosting commented on 12 January 2020

That throws an error on any updated ticket.

Sync for ticket 32018 is blocked

Error Detail Message:

Unexpected error occurred. Generate an exalate support.zip file and contact support.

Error Stack Trace

com.exalate.api.exception.bug.BugException: Unexpected error occurred. Generate an exalate support.zip file and contact support. at com.exalate.error.services.BugExceptionCategoryService.generateBugException(BugExceptionCategoryService.scala:20) at com.exalate.replication.services.replication.in.RequestProcessorService$$anonfun$processSyncRequest$3$$anonfun$1.applyOrElse(RequestProcessorService.scala:165) at com.exalate.replication.services.replication.in.RequestProcessorService$$anonfun$processSyncRequest$3$$anonfun$1.applyOrElse(RequestProcessorService.scala:158) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346) at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: java.util.concurrent.ExecutionException: Boxed Error at scala.concurrent.impl.Promise$.resolver(Promise.scala:55) at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:47) at scala.concurrent.impl.Promise$KeptPromise.(Promise.scala:324) at scala.concurrent.Promise$.fromTry(Promise.scala:142) at scala.concurrent.Future$.fromTry(Future.scala:483) at com.exalate.replication.services.processor.ChangeIssueProcessor$$anonfun$changeIssue$1$$anonfun$apply$1.apply(ChangeIssueProcessor.scala:60) at com.exalate.replication.services.processor.ChangeIssueProcessor$$anonfun$changeIssue$1$$anonfun$apply$1.apply(ChangeIssueProcessor.scala:47) at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253) at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251) … 7 more Caused by: scala.NotImplementedError: an implementation is missing at scala.Predef$.$qmark$qmark$qmark(Predef.scala:230) at services.node.hubobjects.NodeHelper.getOption(NodeHelper.scala:102) at com.exalate.api.hubobject.jira.INodeHelper$getOption.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124) at Script60.run(Script60.groovy:10) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:345) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:145) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at com.exalate.processor.ExalateProcessor.execute(ExalateProcessor.java:69) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:40) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:33) at com.exalate.replication.services.processor.ChangeIssueProcessor$$anonfun$changeIssue$1$$anonfun$apply$1$$anonfun$4.apply(ChangeIssueProcessor.scala:68) at scala.util.Try$.apply(Try.scala:192) at com.exalate.replication.services.processor.ChangeIssueProcessor$$anonfun$changeIssue$1$$anonfun$apply$1.apply(ChangeIssueProcessor.scala:61) … 10 more

Answer by David Oosting on 09 January 2020

Error Detail Message:

Script error for issue 30581. Details: Field with key Remote Status wasn’t found. Please review your script.

With

issue.customFields.“Remote Status”.value = replica.status.name

No errors with

issue.customFields.“360023300132”.value = replica.status.name

but then again…the field isnt being populated.


Answer by David Oosting on 09 January 2020

But we use the status also in our lists

Currently you can see that the Jira Ticket Status is not being set from Exalate. We used the Jira Plug-in Before and it created variables it looks like that zendesk used.


Answer by David Oosting on 09 January 2020

André,

Zendesk makes custom fields as a number. I have 360023300132 as the field i want to fill. So should it be:

issue.customFields.“360023300132”.value = replica.status.name

???

Thanks

Dave


Comments:

André Leroy-Beaulieu Castro commented on 09 January 2020

Yes try that out (old community)

Answer by David Oosting on 09 January 2020

Well… we dont want to set the Zendesk ticket status, we just want to populate the data variable in zendesk,


Comments:

André Leroy-Beaulieu Castro commented on 09 January 2020

I don’t know what you mean by “data variable”, is this a custom field? and I understand that you don’t want to set the zendesk status, what I suggested earlier doesn’t set the Zendesk status, it just gets the status from Jira and sets it into a custom field in Zendesk.

Thanks,

André

Answer by André Leroy-Beaulieu Castro on 09 January 2020

Hi David,

What type of custom field is this on Zendesk? You are trying to set a value of type “option” which might be the problem, if you want to set only the status name to a custom field of type String, it would look like:

issue.customFields."Remote Status".value = replica.status.name

of course the “Remote Status” custom field must be of type string.

Thanks,

André