How can I make component/s single value only?

How can I make component's single select?

3 answers

1 accepted

0 vote

You can't natively.  Options though:

  1. Use a validator to refuse entry of more than one (there are several plugins on the marketplace that can provide that validator).  I'd avoid that one, as it's ugly for the users
  2. Hack the "edit" field template for component so that it is only single select.  Neat, but you have to maintain it in upgrades etc
  3. Use the Script-Runner Behaviour plugin to amend the field type 
  4. Write your own javascript to amend the field type.

I'm not averse to option 2 if you need a global change, but it does add testing burden to your upgrades.  Option 3 is probably the best one.


As follow up to Nic's answer, I'm listing here how one can do using Script Runner Behavior

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours

def components = getFieldById("components").getValue() as List<ProjectComponent>
if (components.size() > 1){
getFieldById("components").setError("Please select only one component related to your work.")

Hope that helps to anyone who still looking for easy way to get it done for specific project.

Anybody know what the script would be to check if component has more than one entry?

What type of script?

Groovy / Script Runner

I added a solution for the JIRA version 6.4.13 in the ticket

 JRA-12543 - Need ability to change project component field type from multi select to single selectCLOSED ,

hope it helps.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

732 views 3 11
Read article

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