You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.