Check sub-task status in Post-Function and stop from transition if sub-task still in Open status.

Hello,

 

I have added transition in a workflow from status "In Review" to "QA Open". This transition set with option triggers "Automatically transitions the issue when a related pull request is merged".

I noticed that Triggers will ignore Conditions and Validators.

Atlassian support suggest to create groovy script to be add in ScriptRunner in Post Function.

I am quite new in creating this groovy script. Does anyone has script example to check sub-task status in Post-Function and script example to stop from proceed transition.

2 answers

Hi Farhan,

This might be quite straight-forward in your use case. You could use a built-in script called "Fast-track transition an issue" with a condition added to it. That would limit the amount of Groovy that you need to write.

You can find a good example of it in the documentation https://scriptrunner.adaptavist.com/5.2.4/jira/builtin-scripts.html#_fast_track_transition_an_issue

This approach works by transitioning the issue back to its original state rather than "stopping" the transition (hopefully this would work for your use case).

Here is an example of some code that will retrieve the sub-tasks for an issue that you can use in the condition field. You just need to add the condition that you want to check on and return the relevant value (see built-in examples for condition field)

issue.getSubTaskObjects().each{ subtask ->
println(subtask.id)
}

 I hope this helps!

Steve

Thanks Steve,

As your suggestion, I have created 2 transition.

  1. Transition1 for the trigger which loop back to original state. At the Post Function I use the Fast-track transition and just leave the condition blank as it will assume as true then Action to Transition2. (In this transition I add condition hide transition from user)
  2. Transition2, linked to next state with condition to check sub-task status.

It works like charm :)

Glad to hear it worked :-)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

1,170 views 4 5
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