Creation of new sub-task

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

This widget could not be displayed.
Vasiliy Zverev Community Champion Feb 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.

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

Script Postfunction.JPG

Vasiliy Zverev Community Champion Feb 18, 2016

You need Create sub-task option.

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

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 Community Champion Feb 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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

157 views 2 0
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