Hello,
I am trying to update a Script runner example script for our needs and I am having trouble checking a sub-task field value. Please assist. Thanks.
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTasks = issue.getSubTaskObjects()
subTasks.each {
if (it.statusObject.name == "Done" && it.cfValues['Deployed in Environment']*.value.contains('Test')) {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
// setResolutionId("1") // resolution of "Fixed"
setComment("Moving subtasks to ToDo from Parent Deployment Request")
setSkipScreenCheck(true)
}
// validate and transition subtask
def validationResult = issueService.validateTransition(user, it.id, 111, issueInputParameters)
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
if (! issueResult.isValid()) {
log.warn("Failed to transition subtask ${it.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.warn("Could not transition subtask ${it.key}, errors: ${validationResult.errorCollection}")
}
}
}