Skip to main content
Example scripts
arrow icon
To homepage
Jira
Cloud icon
Cloud

Create Sub-tasks when an Issue is Created

Created 1 year ago, Updated 0 day(s) ago
App in script
ScriptRunner For Jira
ScriptRunner For Jira
by Adaptavist
Compatibility
compatibility bullet
Jira
Language |
groovy
def eventIssue = Issues.getByKey(issue.key as String)

if (eventIssue.issueType.subtask) { // If the newly created issue is a subtask, skip the execution
    return
}

def listOfsummaries = ['Subtask summary 1', 'Subtask summary 2'] // The summaries to use for
def subtaskIssueType = 'Sub-task' // The Sub Task Issue Type to Use

def projectKey = eventIssue.getProjectObject().key

listOfsummaries.forEach { summary ->
    eventIssue.createSubTask(subtaskIssueType) {
        setSummary(summary)
    }
}
Having an issue with this script?
Report it here