The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to Set a Default Component when create a Issue?

xinan liu
Contributor
May 26, 2015

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Kevin Lynch
February 16, 2021

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"]

Manvisha Kodali
June 21, 2021

this worked for me, thanks :)

0 votes
Vladislav
Contributor
February 18, 2021

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])   
0 votes
Amanda Lang
August 12, 2019
0 votes
Avinash Singh
Contributor
February 8, 2017

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.