Forums

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

Unable to import a class in groovy script

Abraham_Nkoumbé May 18, 2020

Hi guys, I'm pretty new to jira and scriptrunner.

I'm trying to load some sample code in the script console, but none of them are working :-(

What ever I try, I've got an error message when trying to load a class.

 

For example; with

import com.onresolve.jira.groovy.user.FormField
import com.onresolve.jira.groovy.user.FieldBehaviours
def OriginalEstimate=getFieldByName('Original Estimate')

 

I Have:

Script1.groovy: 1: unable to resolve class com.onresolve.jira.groovy.user.FormField @ line 1, column 1. import com.onresolve.jira.groovy.user.FormField

(same on line 2)


Am I doing something wrong ? Thanx for your help

Best regards...Larry

2 answers

0 votes
Kristian Walker _Adaptavist_
Community Champion
May 18, 2020

Hi Abraham,

Thank you for your question.

I can confirm that the reason that your code above will not work inside of ScriptRunner for Jira Cloud is due to the fact the code you have provided is fro ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud like they do in Jira Server.

You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.

We would recommend reviewing the documentation for ScriptRunner for Jira Cloud which is located here along with the Jira Cloud Rest API Documentation in order to see how the REST API's work in Jira cloud.

I hope this information helps.

Kind Regards,

Kristian

Abraham_Nkoumbé May 19, 2020

Hi Kristian,

Yes very helpful. I wanted to perform some tests with script runner in a dev environment before updating a workflow in my office. My office environment is on a Jira Server. So now  I guess that doing my test on a cloud environment might not be appropriated

Kristian Walker _Adaptavist_
Community Champion
May 19, 2020

Hi Abraham,

I can confirm the API's for Jira Cloud and Server are different as mentioned above which means you will not be able to test a feature for Server on Cloud.

Instead I would advise setting up a local version of Jira Server with ScriptRunner for Jira Server so you can test the server code you need before you put into your office environment.

I hope this helps.

Kristian

0 votes
Tom Lister
Community Champion
May 18, 2020

Hi @Abraham_Nkoumbé 

Not all classes are available in all script runner editors

FormField and FieldBehaviours are part of the Behaviours implementation and wouldn't make sense in the Script Console.

I assume you've pasted a Behaviours example in the console.

What are you trying to perform?

Tom

Abraham_Nkoumbé May 19, 2020

Hi, Tom Thanks for your answer. Now it's clearer.
I just need to implement a condition validation on a workflow based on a field value. I saw in the recent version of Jira, that there is a "Field Value" builtin condition, but unfortunately, at work, we have an old version without this possibility. On the other hand, I have the option to set a script runner condition.
So I was just experimenting to find the good syntax to compare a field with a numeric`value. For experimented users, that is nothing, but when you don't know how...its not obvious

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events