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")


Thanks a lot! We will give it a try.

0 votes

You can also insert menu items using the examples here: 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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,975 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot