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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.