Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,101
Community Members
 
Community Events
168
Community Groups

Groovy - how to check if an issue is a sub-task

Hi

I am building a custom scripted validator in Groovy and within my script I need to identify whether the current issue is a type of sub-task.  Is there a way I can check this?

1 answer

1 vote

Hi @Graeme Johnson 

The sure is a way to check this and it's very easy:

if( issue.issueType.subTask){
//do something for sub-task issue types
} else {
//do something for parent issue types
}

Thanks, that worked a charm.  

What if we want to check if current issue contains a particular Sub-Task named "abc" ?

You could try something like this:

def abcSubtaskFound = false
if(issue.subTaskObjects){
abcSubtaskFound = issue.subTaskObjects.any{it.issueType.name == 'abc'}
}

Or as a oneliner:

def abcSubtaskFound = issue.subTaskObjects && issue.subTaskObjects.any{it.issueType.name == 'abc'}

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events