Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to Set a Default Component when create a Issue?

As the title says, I want to auto fill a defaule component when create a issue. Can JIRA or some plugin can do this? I have searched for some old questions about this title, the answers are all negative. Is there some more achievements?

How do I set the component field to a default value for a create (before it's entered)

How to auto-assign a 'Component' default value when creating a new issue?

5 answers

Using a scriptrunner Behavior, I was able to assign a default component.

---

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.*

// set Components
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
def component = getFieldById(COMPONENTS)
if (! component.getValue()) {
component.setFormValue(components.findAll { it.name in ["Component name from the list"] }*.id)
}

---

You can also assign multiple components by changing the ["Component name from the list"] to ["Component name from the list", "Other component name"]

this worked for me, thanks :)

Hello,

Try this as post-function:

import com.atlassian.jira.component.ComponentAccessor
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
projectComponentManager.findAllForProject(issue.projectObject.id)
def component = projectComponentManager.findByComponentName(issue.projectObject.id, "YOUR COMPONENT HERE")
issue.setComponent([component])   

I would also like to know if this is possible. Its seems that you can only set default values on custom fields.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you