Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,463,473
Community Members
 
Community Events
176
Community Groups

Transit parent issue based every child's status

Edited

Hello everyone!

I've been trying to use a groovy script to transition the Parent to the transitionid "31" when transitioning any Subtask with the ID type "13103", but only if everyone of this subtask's sibling tasks are on "Horas Aprovadas" status:

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue

Integer actionId = 31 // The transition ID

MutableIssue parent = issue.getParentObject() as MutableIssue
IssueService issueService = ComponentAccessor.getIssueService()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
TransitionOptions transitionOptions = new TransitionOptions.Builder()
.skipConditions()
.skipPermissions()
.skipValidators()
.build()

IssueService.TransitionValidationResult result = issueService.validateTransition(currentUser,
parent.getId(),
actionId,
issueService.newIssueInputParameters(),
transitionOptions)

List<MutableIssue> otherSubtasks = parent.getSubTaskObjects().findAll{it.getIssueType().getId() == ("13103")}

if (otherSubtasks.every{it.getStatus().getName() == "Horas Aprovadas"}) {
issueService.transition(currentUser, result)
} else {
}

 

But it doesn't seem to be working.

Could anyone help me?

1 answer

1 accepted

1 vote
Answer accepted

I'm guessing you are doing this as part of the transition postfunction for the subtask when moving to your target status.
"otherSubTasks" will include the current subTask and it will not be in that status yet.

Try

def otherSubtasks = parent.subTaskObjects.findAll{it.issueType.id == "13103" && it != issue }

if (otherSubtasks.every{it.status.name == "Horas Aprovadas"}) {
issueService.transition(currentUser, result)
}

Thank you so much, Peter!

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events