The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Static type checking failed in script editor in Script Runner plugin while using get method

Hitendra Chauhan
Contributor
January 8, 2020

I am new to Script Runner and trying to just get Flagged custom field. the following code is copied from internet and read somewhere that get method is automatically available in the console, but it seems it is not.

Can some one help ?

Code:

def flaggedCustomField = get("/rest/api/2/field").asObject(List).body.find {
(it as Map).name == 'Flagged'
} as Map

 

Error:

2020-01-08_16-27-01.png

2020-01-08 09:19:38,743 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-01-08 09:19:38,744 ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.get() is applicable for argument types: (java.lang.String) values: [/rest/api/2/serverInfo] Possible solutions: get(java.lang.String), getAt(java.lang.String), grep(), put(java.lang.String, java.lang.Object), grep(java.lang.Object), wait() at Script749.run(Script749.groovy:1)

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
brbojorque
Community Champion
January 8, 2020

Hi @Hitendra Chauhan ,

The code you provided only works in Jira Cloud ScriptRunner.

Here's the equivalent code for Jira Server.

import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customFields = customFieldManager.getCustomFieldObjects()
log.debug(customFields)
def flaggedCF = customFields.find{ it = "Flagged" }
flaggedCF