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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.