Get fields, Resolutions, and Issue Types from Jira


Use ScriptRunner for Jira to get field, issue type, and resolution information. Using this script, you can get the ID and use it to update other issue information.


I am a ScriptRunner user and I want to implement a new script. To create this script I need to know the IDs of the fields in Jira. With this script I can get the IDs by adding the names of these fields to the script.

Good to Know

  • The IssueTypes, Field or Resolutions names must be written as a list of strings as shown in the script.
  • If the element name does not exist, you will not get any value for it.


Jira Jira

// Name of the elements for which you want to get the id def issueTypesNames = ['Story'] def fieldNames = ['Summary'] def resolutionNames = ['Done'] // Elements information maps def issueTypesMap = getIssueTypeIdsFromNames(issueTypesNames) def fieldsMap = getFieldIdsFromNames(fieldNames) def resolutionsMap = getResolutionsFromNames(resolutionNames) "IssueTypes: ${issueTypesMap} - Fields: ${fieldsMap} - Resolutions: ${resolutionsMap}" Map getIssueTypeIdsFromNames(Collection issueTypesNames) { def result = issueTypesNames.collectEntries { issueTypeName -> def issueTypeObject = get('/rest/api/2/issuetype') .asObject(List) .body.find { (it as Map).name == issueTypeName } as Map issueTypeObject ? [(issueTypeName.toString()):] : [:] } result as Map } Map getFieldIdsFromNames(Collection fieldNames) { def result = fieldNames.collectEntries { fieldName -> def customFieldObject = get('/rest/api/2/field') .asObject(List) .body.find { (it as Map).name == fieldName } as Map customFieldObject ? [(fieldName.toString()):] : [:] } result as Map } Map getResolutionsFromNames(Collection resolutionNames) { def result = resolutionNames.collectEntries { resolutionName -> def resolutionObject = get('/rest/api/2/resolution') .asObject(List) .body.find { (it as Map).name == resolutionName } as Map resolutionObject ? [(resolutionName.toString()):] : [:] } result as Map }
Discovered an issue? Report it here

Suggested for you

Appears in these Collections