Populating Single Select List in transition form with Behaviours


I am trying to build a Single Select List of Issue Keys that are in the current project that is related to the issue.

I figured that the Behaviour plugin with server side script would be the way to go.

The idea is to get all the Keys from the project and allow the user to select one, however I get a validation error.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.info("Starting Behaviour GroovyScript PopulateIssueIds")

def issueId = formContents["id"]
def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(issueId as Long)
def project = issue.getProjectObject()
def issuesIds = ComponentAccessor.getIssueManager().getIssueIdsForProject(project.getId())
def issues = ComponentAccessor.getIssueManager().getIssueObjects(issuesIds)

Map fieldOptions = [:]
for(MutableIssue tempIssue : issues){
 log.debug("ID: "+tempIssue.getKey())

FormField targetIssue = getFieldById("customfield_11803")

The population of the list works

But when I try to transition the issue I get an error

Invalid value '13915' passed for customfield 'Target Issue'. Allowed values are: , -1

I suspect it because these values are not defined in the Custom Field as valid options?

Is there something I am doing wrong here or am I limted to only having predefined values, even if I can reduce the options shown?

If so is there some other approach that could acheive the same goal?

2 answers

1 accepted

0 votes

Yes, jira will only let you use valid options for a select list.

It's possible to use a plain text field but style it as a select list so it behaves like fixversions or something, but unless you're pretty good with javascript it might not be worth doing.

ok, thanks for the response. I figured I may have to go down the plain text field list.

Screen Shot of error

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,006 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot