How to create subtask with name from parent's name

I am thinking to user Groovy to create two customerized sub-menus, one for sub-tasks' creation and another for sub-tasks' update. 

The sub-tasks' summary is like "'Sub 1 - %parent summary%", and assigned to a user, with user name from a fraction of the value of one parent tasks's customField, which is like "user1, 10, user 2, 11, user 3, 12". For example, the assignee of one sub-task is "user 1" (auto matched). And the estimation will be converted from "10"; assignee of anothe sub-task is "user 2", with an estimation converted from "11"

And once the parent's customerField is changed, we can use the "update" menu to update the assignee and estimation. 


I am a newbie of Groovy, can anyone give some hint or idea how to do this? Thanks a lot in advanced!

2 answers

Hi Julie,

What do you mean by sub-menu for sub-task. Are you looking to create sub-task based on workflow post function if yes then you could use something like this

In Post-Function Create Sub-task and in Additional issue actions insert script something like this. First it appends sub-task summary as some text + Parent summary and then based on value of custom field value it set assignee, similarly you can do for estimation field

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.user.util.UserUtil

def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def cf = customFieldManager.getCustomFieldObjectByName("Category") //use your custom field name here

def cat = (issue?.getCustomFieldValue(cf) as Option)?.value

MutableIssue issue = issue
issue.summary = 'NEW TASK: ' + sourceIssue.summary
if (cat== "test2")
{
issue.setAssignee(ComponentAccessor.userUtil.getUserObject("jirausername"))
}

Taha

Thanks a lot! We will give it a try.

You can also insert menu items using the examples here: https://scriptrunner.adaptavist.com/latest/stash/CustomisingUI.html. They are for Stash but it's the same principal for JIRA, although it's probably a bit more involved than you'd want if you haven't done anything like this before.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,476 views 15 19
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you