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?
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)
}
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.