Forums

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

How can I validate the Issue that must have at least one "Child of" linked issue?

Diego Chen
Contributor
September 13, 2024

 

When I change the status from "in progress" to "Closed". I want to validate the Issue that must have at least one "Child of" linked issue and all "Child of" linked issues are “Closed”.

1 answer

1 accepted

1 vote
Answer accepted
Tuncay Senturk
Community Champion
September 13, 2024

Hi @Diego Chen 

You can't do that with out-of-the-box Jira. But, you can achieve this using ScriptRunner if you are free to use an app.

Add a ScriptRunner script validator for your workflow transition. The script will be similar to the one below, there might be some issues with the code but I trust it will be a good start.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.workflow.WorkflowFunctionUtils


def issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager)

def childOfLinks = issueLinkManager.getOutwardLinks(issue.id).findAll { link ->
link.issueLinkType.name == "Child of"
}


if (childOfLinks.isEmpty()) {
// No "Child of" linked issues, validation fails here
return false
}

def allLinkedIssuesClosed = childOfLinks.every { IssueLink link ->
link.destinationObject.status.name == "Closed"
}

return allLinkedIssuesClosed

 

Suggest an answer

Log in or Sign up to answer