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

Groovy expression to see if there are any subtasks?

Cole Aug 31, 2017

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

0 votes
Evan Winter Aug 31, 2017

Try this?

def subTasksList = issue.getSubTaskObjects()

if (subTasksList.size() < 1) {
return true
}
Cole Aug 31, 2017

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: []

Evan Winter Aug 31, 2017

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

Cole Aug 31, 2017

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

Evan Winter Aug 31, 2017

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

import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
Evan Winter Aug 31, 2017

Perhaps also 

import com.atlassian.jira.issue.Issue 
Cole Aug 31, 2017

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Off-topic

Disney Live Action Reboots: Are you for or against?

Happy Friday Everyone! Today marks the international release of Disney's live action version of the animated classic Aladdin. I know that this movie was met with some controversy of over cast...

139 views 19 8
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