I have a script that I've added to the Close transition as a validator.
Here's the script:
package Workflows.Validators
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import org.apache.log4j.Level
import Log****.*
import Log****.Helpers.*
Logger jiraLog = Logger.getLogger(this as String)
jiraLog.setLevel(Log****Locale.logLevel)
// Get the current issue
Issue parentIssue = issue
jiraLog.debug('Source Issue: ' + parentIssue.getKey())
if (parentIssue.getSubTaskObjects().size() > 0) {
def subTasks = parentIssue.getSubTaskObjects()
jiraLog.debug('Associated sub-tasks: ' + subTasks)
def allSubTasksDone = subTasks.every { it.status.name in ['Closed'] }
jiraLog.debug(allSubTasksDone)
if (!allSubTasksDone) {
jiraLog.debug('Got to the part where all sub-tasks are not closed.')
UserMessageUtil.info('Cannot close issue ' + parentIssue + ' as it has open sub-tasks')
return false
}else {
jiraLog.debug('All sub-tasks are closed.')
return true
}
}
if (parentIssue.getSubTaskObjects().size() == 0) {
jiraLog.debug('No sub-tasks associated with issue: ' + parentIssue)
return true
}
Hi @Jeramy ,
If you are using Custom script validator, then you need to throw an InvalidInputException instead of returning false.
So, just change
return false
tothrow new InvalidInputException("...")
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.