Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Cloud + ScriptRunner -> Script to get time in status gives an error

gabriel.olteanu February 25, 2022

Hello,

 

I'm using the Jira Cloud version + ScriptRunner For Jira (add-on).

 

I want to create a custom field for each of my jira issue where I want to calculate the time spent in the status "In Progress" for each issue and display it in a custom field (in each issue).

 

I found the following script on the Adaptavist library:

https://library.adaptavist.com/entity/count-the-time-an-issue-was-in-a-particular-status

 

But When I try the script I get the following errors (NOTE: I'm not a software developer):

 

Seems to me he cannot import the following libraries:

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.history.ChangeItemBean

(seems like they don't work in Jira cloud... just guessing here)

Anyone know how to make that sample script work in the Jira Cloud Version? Thanks

 

Error

An error occurred whilst running the scripted field.

 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: unable to resolve class com.atlassian.jira.component.ComponentAccessor @ line 1, column 1. import com.atlassian.jira.component.ComponentAccessor ^
Script1.groovy: 2: unable to resolve class com.atlassian.jira.issue.history.ChangeItemBean @ line 2, column 1. import com.atlassian.jira.issue.history.ChangeItemBean ^
2 errors at
com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:48) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:31) at com.adaptavist.sr.cloud.events.ScriptedFieldExecution.run(ScriptedFieldExecution.groovy:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at TestScriptedFieldExecution1_groovyProxy.run(Unknown Source)

1 answer

0 votes
bravesightlimited March 5, 2022

FYI, that code is for Jira Server, but not Jira Cloud. I doubt this is your issue, as I'm seeing something similar with a simpler piece of code:

 

return "Hello world!"

 

For a text field.

 

I'm about to raise a support ticket for this and will post the response, as it will hopefully help someone.

Suggest an answer

Log in or Sign up to answer