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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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

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

0 votes
Answer accepted
brbojorque Community Leader Jan 08, 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

Suggest an answer

Log in or Sign up to answer
TAGS

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