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