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

Jira Cloud - Transition Sub-task when parent is transitioned

Hi Guys.

I'm using Jira Cloud and Script Runner, and need to transition all subtasks to a certain status when the parent issues is transitioned.

Which would be the best way to achieve this?

1 answer

1 accepted

1 vote
Answer accepted

Hi Vando Eduardo de Brito Goncalves,

Thank you for your question.

I can confirm that it is possible to achieve your requirement using ScriptRunner for Jira Cloud and can confirm that to achieve this that you would need to create a Script Listener which is configured on the Issue Updated event.

The script listener would need to check the status of the updated issue and would then need to fetch the subtasks for the issues attached to it in order to check that the status of all subtasks to check if they are all in the required status and if they are to transition the Parent issue

Please note we have some example code located here which shows how to return all of the subtasks for an issue as well as some example code located here which shows how to transition an issue.

I can also confirm that we have an example script located here which shows how to transition an issue when all linked issues are in the closed status and that this script may be a useful reference guide.

You will be able to take these script and use them as a reference guide to help create the script that you require which transitions the story issues when all subtasks are in the done status.



Thanks for your prompt reply @Kristian Walker _Adaptavist_ !

Your informations gave me some guidance on how to start. The only detail I wanted to highlight it's that I want to transition the sub-tasks when the main issue is transitioned.

Once again, thanks a lot !

Hi Vando,

Thank you for your response.

I can confirm in this case you can just check if the status of the parent issue changed in the change history and if it did then you can run some code to transition the sub-tasks.



As it might be useful for someone else, here's how I addressed this:

As I needed the sub-tasks to be transitioned when the task was transitioned, I added the below code as a Script Runner arbitrary code post function:

// Specify the transition to execute on the issue
// NOTE - The transition ID must represent a valid transition for the workflow that the issue uses.
def transitionID = '<TransitionIDHere>'

// Note: The search API is limited that to only be able to return a maximum of 50 results
def allSubtasks = get("/rest/api/2/search")
.queryString("jql", "parent=${issue.key}")
.issues as List<Map>

// The rest call to transition the issue

def transitionIssue = allSubtasks.each{
def transitionIssue = post("/rest/api/2/issue/$it.key/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: transitionID]])


Suggest an answer

Log in or Sign up to answer

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