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 add dynamic options into a Select List custom field using groovy

I want to fetch the value of a custom field(Number type) and system field "Summary" and concatenate the two to make options of a select list custom field. 

The issues are fetched by JQL query which is triggered in the same behavior and the results can be iterated.

Could anyone please help me with that.

Any help would be appreciated.


Swapnil Srivastav


1 answer

Here is the code that I tired:

import com.atlassian.jira.component.ComponentAccessor


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

import com.atlassian.jira.web.bean.PagerFilter

import com.atlassian.jira.groovy.user.FieldBehaviours

import com.atlassian.jira..issue.customfields.manager.OptionsManager

import com.atlassian.jira.issue.IssueManager

import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours




  def customFieldManager = ComponentAccessor.getCustomFieldManager()

  def umbApp = customFieldManager.getCustomFieldObjectByName("Name of select list")

 def optionsManager = ComponentAccessor.getOptionsManager()

 def fieldConfig = umbApp.gettRelevantConfig(getIssueContext())

 def options = optionsManager.getOptions(fieldConfig )

 def umbAppMap =[:]

 umbAppMap.put("-1", "None")

 def uNum = customFieldManager.getCustomFieldObjectByName("Name of Number field")


 def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)

 def searchProvider = ComponentAccessor.getComponent(SearchProvider)

 def issueManager = ComponentAccessor.getIssueManager()

 def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

 def query = jqlQueryParser.parseQuery("project ='XXX' AND issuetype = XXX")

def results =, user, PagerFilter.getUnlimitedFilter())




   results.getIssue().each{ documentIssue ->

      def issue = issueManager.getIssueObject(

      def unumValue = (Integer) issue.getCustomFieldValue(unum)

      def umbAppOption = "U-"+unumValue+" "+issue.summary

      umbAppMap += options.findAll { it.value in [umbAppOption]}.colectEntries{

         [(it.optionId.toString()) : it.value]}








Even if I set the options as (just to test):

umbAppMap += options.findAll { it.value in["Hello", "Hi", "Hola", "Adios"]}.collectEntries{

[(it.optionId.toString()): it.value]}


Then also, I am getting an error in the last line:


The error is :

Cannot find matching method.


Kindly correct the code



Suggest an answer

Log in or Sign up to answer

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