how do I prevent the multi-select of component?

Hello, I am trying to prevent users from selecting more than one component when creating, or editing an issue. Is this possible?

Thanks

1 answer

Hi Udo - thanks. I installed plugin - followed steps but I'm still able to select mutiple components when creating or editing an issue. no errors are generated when I save the server side script, but other behaviours that I ghave setup for test appear to be working OK.

Here is the script I'm using: - (are you able to see what I'm doing wrong?)

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.ComponentManager

class SingleComponentOnly extends FieldBehaviours {

ComponentManager componentManager = ComponentManager.getInstance()

public void allowOnlySingleComponent() {
FormField formComponent = getFieldById(fieldChanged)

// if it's a list it has more than one value
if (formComponent.getFormValue() instanceof List) {
formComponent.with {
setValid(false)
String s = "Please select only one component."
setTitle (s)
setHelpText("<div class=\"warningBox\">$s</div>")
}
}
else {
formComponent.with {
setValid(true)
String s = ""
setTitle (s)
setHelpText("")
}
}
}
}

Hi James,

Unfortunately I'm not able to see why it is not working. But I saw that you already asked that question.

https://answers.atlassian.com/questions/235984/behaviours-plugin-how-to-prevent-multi-select-on-components-field

Maybe you will get an answer there.

yeah, albeit a slightly different question - the other question relates to why the code copied from the website doesn't compile, but if I change 'package' to import at the top of the code then it compiles, but doesn't work...

Hi James,

did you manage to get a working code to prevent the multi-select of Components?

 

Thanks,

Corentin

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,323 views 14 20
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