Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make component/s single value only?

clem
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

How can I make component's single select?

3 answers

1 accepted

3 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

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.

 

Raju Kadam
Contributor
May 15, 2018

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.

Like 7 people like this
Alex Gallien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2021

Thanks for sharing that code Raju! Saved me the time to figure it out myself :)

Like Cyril Egan likes this
0 votes
Massimo Prevignano July 17, 2016

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.

0 votes
clem
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

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

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

What type of script?

Lacey McDonnell November 10, 2016

Groovy / Script Runner

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, out of office, loom, confluence, async collaboration, meeting recaps, remote teamwork, team alignment, knowledge sharing, AI-powered notes, productivity tools, workforce continuity, teamwork collection

Put your meeting notes on autopilot with Loom + Confluence

AI-powered meeting notes keep work moving even if you’re out of the office. Enjoy your well-deserved time off and return refreshed, confident you’ll catch up in no time.

Learn more
AUG Leaders

Atlassian Community Events