Creation of new sub-task

Vinay Shekar February 17, 2016

We have around 8 sub-tasks (A,B,C,D,E,F,G,H) created automatically when a new Jira ticket is created.

There was a requirement came from management where on closing of first 4 sub-task (A,B,C, D) it should create another sub-task (I) and on closing of next 4 sub-task (E,F,G,H) it should create another sub-task (J).

Please let me know how we can achieve this?

Thanks in advance.

Regards
Vinay

1 answer

0 votes
Vasiliy Zverev
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.
February 17, 2016

Here is an idea for postfunction to do this:

import com.atlassian.jira.issue.Issue

/**
 * Creates new subtasks based on statuses of other subtasks
 */

int closed_A = 0;
int closed_b = 0;

for(Issue subtask: issue.getSubTaskObjects()){
    if(true)//check if subtask is one of A, B, C or D
        if(subtask.getStatusObject().getName().equals("Closed"))
            ++closed_A;
    
    if(true) ////check if subtask is one of E, F, G or H
        if(subtask.getStatusObject().getName().equals("Closed"))
            ++closed_b;
}

if(closed_A ==  4){
    //create I
}

if(closed_b == 4){
    //create J
}

Perhaps it will be interesting for you:https://answers.atlassian.com/questions/32982259

Also I would recommend you to use Script PostFunction or CreateSubtask postfunction provided ScriptRunner plugin to run this code.

Vinay Shekar February 18, 2016

Hi Vasiliy,

Thanks for the answer. You mean to say I need to add this post function on all the sub-tasks Closed status?

Can you confirm which option to select from Script Postfunction? Because I can see two similar option as per the attached screenshot.

 

Also can you let me know how to create Sub-tasks I and J when the count ==4?

 

Again thanks for your help.

 

Thanks

Vinay

Vinay Shekar February 18, 2016

Script Postfunction.JPG

Vasiliy Zverev
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.
February 18, 2016

You need Create sub-task option.

Vinay Shekar February 19, 2016

Hi vasiliy,

 

Need your further help wrt to configuration.

Please let me know if the configuration as attached in the scrrenshot works. Do I need to add any more configuration.

Script Postfunction.JPG

Thanks

Vinay

Vinay Shekar February 19, 2016

Hi vasiliy,

 

Need your further help wrt to configuration.

Please let me know if the configuration as attached in the scrrenshot works. Do I need to add any more configuration.

 

Conf.JPG

 

Thanks

Vinay

Vasiliy Zverev
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.
February 19, 2016

Idea is follows: condition is a some boolean expression which returns "true" when you need to create a sub-task.

Here is a code for validator which checks that it requared to create a sub-task I:

import com.atlassian.jira.issue.Issue

/**
 * Creates new subtasks based on statuses of other subtasks
 */

int closed_A = 0;

for(Issue subtask: issue.getSubTaskObjects()){
    if(true)//check if subtask is one of A, B, C or D
        if(subtask.getStatusObject().getName().equals("Closed"))
            ++closed_A;    
}

if(closed_A ==  4){
    return true
} else {
    return false
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events