Can JIRA automatically create a specified number of subtasks when you create an (main) Issue in JIRA?

Else Stork October 17, 2011

Can JIRA create a specified number of subtasks automatically when you create an (main) Issue in JIRA?

Could it be possible to create an Issue Type in JIRA which could automatically create 3 or 4 Subtasks for this “main” issue. Anyone who have had this requirement before? It will save the time it takes to create all 3 or 4 subtasks after, and best could also be to automatically assign them to the related assignee.

Thanks in advance for any ideas for how to solve this.

3 answers

2 votes
JamieA
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.
November 27, 2011

There is a built-in task for the script runner plugin already.

1 vote
Matt Johnson November 27, 2011

I use the following Groovy script as a post-function to create another issue, but it could easily be modified to create subtasks.

import com.atlassian.core.user.UserUtils  
import com.atlassian.jira.ComponentManager  
import com.atlassian.jira.issue.link.IssueLink  
import com.atlassian.jira.util.ImportUtils  
import com.opensymphony.user.User  
import com.opensymphony.workflow.WorkflowContext  
import org.apache.log4j.Category  
  
log = Category.getInstance("com.onresolve.jira.groovy.CreateDependentIssue")  
  
// Configurable section  
def projectName = "Project"       // Name of project you want to create the issue in  
// for other customizations change the code below  
  
issueMgr = ComponentManager.getInstance().getIssueManager()  
projectMgr = ComponentManager.getInstance().getProjectManager()  
  
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();  
User currentUserObj = UserUtils.getUser(currentUser);  
  
def wasIndexing = ImportUtils.indexIssues  
ImportUtils.indexIssues = true  
issueFactory = ComponentManager.getInstance().getIssueFactory()  
newissue = issueFactory.getIssue()  
newissue.setSummary (issue.summary)  
newissue.setProject (projectMgr.getProjectByName(projectName))  
newissue.setIssueType (issue.getIssueType())  
newissue.description = "new issue description"  
newissue.reporter = issue.getAssignee()
newissue.assignee = issue.getAssignee()
  
params = ["issue":newissue]  
subTask = issueMgr.createIssue(currentUserObj, params)  
println subTask.get("key")

0 votes
Jobin Kuruvilla [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.
October 17, 2011

You can do this in a JIRA Listener.

Jobin Kuruvilla [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.
October 17, 2011

I don't have an example with me at this moment. Btw, Post function also will work. You can add it as a post function on the Create transition. So go ahead and use it if you got it.

Else Stork October 17, 2011

I would really appreciate if you could send me an example of how this could be done.

I also saw an example with JSS script that creates a subtask in a post function.

Thanks,

Suggest an answer

Log in or Sign up to answer