Groovy expression to see if there are any subtasks?

I am trying to use the transition issue post function and want it to only occur if there are no subtasks for that issue. 

I have checked the box "Only if condition is true", but I am unsure what my expression would be to look for subtasks?

 

Basically I would want it to say something like:

If no subtask for current issue {

Return true

}

1 answer

Try this?

def subTasksList = issue.getSubTaskObjects()

if (subTasksList.size() < 1) {
return true
}

I see this error:

No signature of method: com.innovalog.jmwe.IssueProxy.getSubTaskObjects() is applicable for argument types: () values: []
groovy.lang.MissingMethodException: No signature of method: com.innovalog.jmwe.IssueProxy.getSubTaskObjects() is applicable for argument types: () values: []

Are you using Cloud or Server? The above script worked for me using JIRA Server 7.x with the following post function configuration.

jmwe.PNG

I am using JIRA Server 7. Does there not need to be some kind of reference to a class at the top or something?

Try adding these two lines to the top of the script.

import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()

Perhaps also 

import com.atlassian.jira.issue.Issue 

I ended up using a built in script to fast-track a transition. For the condition I used "issue.getSubTaskObjects().size() < 1" and it worked.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted 2 hours ago in Off-topic

Miscellaneous Monday - CreatatronV3

You may remember, not so long ago, that together we invented the most evil of machines: The Destructo5000!  The effects of missing Durian rippled over nations. Complete chaos as goat chee...

35 views 2 2
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