You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
While moving to in progress, sub-tasks would be created for each application selected in Application Name (multiselect)
Summary: <App_Name> - Subtask
Select List 1 : Value from parent task
Text 1: Value from parent task
Number 1: Value from parent task"
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def parentIssue = sourceIssue
int numMarkups
doAfterCreate = {
if (parentIssue.getIssueType().getName() != 'Task')
{return}
if (parentIssue.summary.contains("Markup Master Task"))
{
numMarkups = Integer.parseInt(parentIssue.summary);
}
if (numMarkups >= 50)
{
return
}
else
{
def i = 0
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
for (i; i < numMarkups; i++)
{
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary("Markup" + i.toString())
newSubTask.assignee == parentIssue.assignee
newSubTask.components == parentIssue.getComponents()
newSubTask.setParentObject(parentIssue)
newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "P2" }.id)
newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
it.getName() == "Sub-task" }.id) }
}
}
}
Welcome to the Atlassian Community!
Your
def parentIssue = sourceIssue
is making a nonsense of the script - sourceIssue is not a variable you have any access to in a post-function.
Try removing that line completely, and just using "issue" instead of "parentIssue" when you need to look at the current issue.
Your code is also not looking at the select field, it's taking the number of subtasks from the summary, which, in the real world, is likely to be utter nonsense, it's almost certainly going to be 0 for any issue, so there's no reason the code would go into the loop that creates the sub-tasks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.