Team I am using the following code to validate with scriptRunner in Jira server version 8.20.10, that when transitioning an Epic to the "Done" status, it validates that all
issues in the epic are in a "final" status (StatusCategory == Done)
The following code works fine when I query by status eg:
it?.destinationObject?.getStatus().getName() != 'Done' && it?.destinationObject?.getStatus().getName() != 'Canceled' &&
it?.destinationObject?.getIssueType().getName() != null
but when I try to do it with statusCategory since I contain more than one final status and I would like to simplify the code, it always returns "False".
I am using this code:
it?.destinationObject?.getStatus().getStatusCategory().getName() != 'Done' &&
it?.destinationObject?.getIssueType().getName() != null
I leave you the complete script to help me understand what I'm doing wrong...
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
def issueMgr = ComponentAccessor.getIssueManager()
//Issue issue=issueMgr.getIssueByCurrentKey("OST-83")
// Allow logging for debug and tracking purposes
import org.apache.log4j.Level
import org.apache.log4j.Logger
// Script code for easy log identification
String scriptCode = "Check all issues in Epics are Done -"
// Setup the log and leave a message to show what we're doing
Logger logger = log
logger.setLevel( Level.ERROR )
logger.debug( "$scriptCode Triggered by $issue.key" )
def passesCondition = true
if (issue.issueType.name == 'Epic')
{
IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
def found = issueLinkManager.getOutwardLinks(issue.id).any
{
it?.destinationObject?.getStatus().getStatusCategory().getName() != 'Done' &&
it?.destinationObject?.getIssueType().getName() != null
}
logger.debug( "$scriptCode Found = $found " )
if (found) {
logger.debug( "$scriptCode return false" )
passesCondition = false
invalidInputException = new InvalidInputException("Por favor valide que todos los issues asociados a la epica se encuentren en estado DONE")
} else {
logger.debug( "$scriptCode return true" )
passesCondition = true
}
}
// Always allow all other issue types to execute this transition
else
{
logger.debug( "$scriptCode Not Epic return true" )
passesCondition = true
}
I thank you in advance for your prompt help!
Best regards!!!
Hi @u632570
The value to compare with is not Done but COMPLETE I think.
static String COMPLETE
static String IN_PROGRESS
static String TO_DO
static String UNDEFINED
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.