How can I make component/s single value only?

How can I make component's single select?

3 answers

1 accepted

This widget could not be displayed.

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.")
}
else{
getFieldById("components").clearError()
}

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

This widget could not be displayed.

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

What type of script?

Groovy / Script Runner

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

137 views 1 3
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