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.

0 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

26 views 0 4
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