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?
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What if we want to check if current issue contains a particular Sub-Task named "abc" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if we want to check - Task issue type have any open subtask(open means issue not in any done status category).
then what should be the script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Something like this should work
import com.atlassian.jira.issue.status.category.StatusCategory
issue.subTaskObjects.every{ it.status.statusCategory == StatusCategory.COMPLETE}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you want either
if(issue.subTaskObjects.every{ it.status.statusCategory == StatusCategory.COMPLETE}) return null
throw new InvalidInputException('All open subtasks need to be closed')
Or
if(issue.subTaskObjects.any{ it.status.statusCategory != StatusCategory.COMPLETE}){
throw new InvalidInputException('All open subtasks need to be closed')
}
But what you have right now will throw an error only if ALL (every) subtasks are open. If a single one is closed, the validation will pass.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.