It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,071 views 7 0
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you