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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner scripted field import error

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

1 vote
Answer accepted

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.

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

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

380 views 13 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you