Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scriptrunner scripted field import error

Dawn Rodney March 26, 2021

I'm attempting to use the "Total time this issue has been In Progress" script to add a field to the tickets in a specific Jira Project. After I fill out the necessary fields in the Add New Scripted Fields form, I copy the script and click the Test button. This is the error I get. Any ideas on how I can resolve this?

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)

Thanks for your help!

Dawn

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2021

That looks like a scriptrunner for jira Server/Data Center script ... but you tagged your question as cloud.

You can't import jira server api classes into scriptrunner cloud script.

I'm not sure what the equivalent script for cloud would be.

1 vote
Kate Kabir
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2021

Hi @Dawn Rodney 

It seems that you are using code for the server. This is the reason why you are getting the error. You cannot use a script from the server in a cloud environment. This will not work in a cloud environment. Also, I would also like to share the documentation on the differences between server and cloud environment here

The Scripted Fields as documented inside of the documentation page located here which provides details of how to create new script fields and some examples of what Script Fields can be used for.

Script Fields work using the same process as other scripts such as Script Listeners where you write code that executes rest API calls to either the Jira Cloud Rest API or to your own external rest API call in order to perform an action and to return a value according to the return type you specify as mentioned in the documentation page located here

Finally, I can confirm that Script Fields will appear on either the Issue Content panel or Issue Sidebar depending on what you choose when you configure your script field.

Hope this will help you.

Thank you.

Kind Regards

Kate

Dawn Rodney March 29, 2021

Thank you, Kate. That is very helpful. Is there an example script that will provide me with the "time in progress" similar to the server script that will execute on Jira Cloud? I'm not a dev, so it'd be helpful to not have to write the script from scratch. 

Thanks,
Dawn

Kate Kabir
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2021

Hi @Dawn Rodney 

You are welcome. We don't have an exact example for your requirement but you may kindly refer to all the cloud examples that we have in the documentation here or in the script library here. 

Hope this helps.

Kind Regards

Kate

Kieran Donnelly October 27, 2021

@Dawn Rodney did you ever find a cloud solution to the Time in Status scripted field problem!?

TAGS
AUG Leaders

Atlassian Community Events