How to create subtask with name from parent's name

Julie Y September 13, 2015

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

2 votes
Taha Khanzada
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2015

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

Julie Y September 14, 2015

Thanks a lot! We will give it a try.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2015

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