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

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

How to fetch custom field configuration via script?


I am trying to update an issue's custom field using a Groovy script. 

But if I try to fetch from the issue 

log.debug(issue) // yields JIRA-123, ok!?

def cfField = customFieldManager.getCustomFieldObjectByName("Impact on Architecture")

def cfConfig = cfField.getRelevantConfig(issue)

log.debug(cfConfig) // yields null, not expected!


My config is null. How do I fetch the correc custom field configuration in order to update the option later? 


Here the complete script to reproduce. 

// Version tested Atlassian Jira Project Management Software (v8.5.1#805001-sha1:c5b54a7)

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter

import org.apache.log4j.Level
import org.apache.log4j.Logger

import com.atlassian.jira.jql.parser.JqlQueryParser

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option

def appUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkManager = ComponentAccessor.getIssueLinkManager()
def searchService = ComponentAccessor.getComponent(SearchService.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def jqlSearch = 'project = JIRA'

def issueManager = ComponentAccessor.getIssueManager()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)

def query = jqlQueryParser.parseQuery(jqlSearch)
def log = Logger.getLogger("Jira Log")


CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

OptionsManager optionsManager = ComponentAccessor.getOptionsManager()

SearchService.ParseResult parseResult = searchService.parseQuery(appUser, jqlSearch)

if (parseResult.isValid()) {

def searchResult =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

def issues = searchResult.results.collect {issueManager.getIssueObject(}

issues.each { issue ->

def cfField = customFieldManager.getCustomFieldObjectByName("Impact on Architecture")
log.error "cfField: $cfField"
def cfFieldValue = issue.getCustomFieldValue(cfField)
log.error "cfFieldValue: $cfFieldValue"


if (cfFieldValue.toString().equals("Yes"))

log.debug "cfFieldValue.toString().equals(\"Yes\") is true" // OK!

log.debug(issue) // OK!Returns JIRA-123

def cfConfig = cfField.getRelevantConfig(issue)

log.debug(cfConfig) // null

def Option option = optionsManager.getOptions(cfConfig).getOptionForValue("No", null);
log.error "Found option: $option"



} else {
log.error("Invalid JQL :" + jqlSearch)


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

462 views 5 18
Read article

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