Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Transit parent issue based every child's status

Julia Nunes Pedrosa
Contributor
August 12, 2021

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
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2021

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)
}
Julia Nunes Pedrosa
Contributor
August 13, 2021

Thank you so much, Peter!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events