Forums

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

simple scripted validated where feature cannot be resolved until linked issue are resolved

Heidi Fernandez
December 16, 2025

The feature has linked stories and tasks "child of" link type.  The children must be resolved (done/rejected status) before transitioning the feature to done/reject status.

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Champion
December 16, 2025

Hello @Heidi Fernandez 

Have you considered using the Linked Issues Condition instead? Then you don't have to write a script. But, in that case, the transition would not even be available if the "child of" linked issues are not in the appropriate status, and there would not be any explanation available to the user.

 

There is an answer on this 2021 post that partially addresses your question. The use case there is being applied to all linked issues.

https://community.atlassian.com/forums/Jira-questions/Validate-that-all-linked-issues-are-DONE-ScriptRunner/qaq-p/1660418

Google Gemini provided this information:

Screenshot 2025-12-16 at 11.22.38 AM.png

 

Disclaimer: I don't have a data center environment with Scriptrunner where I can test this.

Heidi Fernandez
December 16, 2025

We tried it and it confused the users.  Using condition, hides the status and they think there is a bug in the browser, etc. They would rather have a error message pop up to tell them what they need to do to do, to transition and why they cannot transition.

Heidi Fernandez
December 16, 2025

I created this and it isn't quite right.  What is missing?  

 

import com.atlassian.jira.component.ComponentAccessor


def children = ComponentAccessor.getIssueLinkManager()
def passCondition = true
def outwardLinks = children.getOutwardLinks(issue.id)


outwardLinks.each { link ->
    if (link.issueLinkType.name == "parent of") {

def destinationIssue =link.destinationObject

    if (!destinationIssue.resolution) {
        passCondition = false
    }
    }
}
Trudy Claspill
Community Champion
December 16, 2025

What results are you getting?

Have you tried testing the code through the ScriptRunner console and adding statements to show output in the console?

Heidi Fernandez
December 16, 2025

It allows the transition no matter what the status is of the linked issues are.  I will try adding statements.

Trudy Claspill
Community Champion
December 16, 2025

I recommend that you work out the code using ScriptRunner Console.

https://docs.adaptavist.com/sr4jc/latest/features/script-console

With that you can test the results of applying the script to an issue without actually having to transition the issue.

You can test your code against specific issues by replacing issue.id with an actual issue id.

Trudy Claspill
Community Champion
December 16, 2025

This code worked for me in the ScriptRunner console when I provided valid input in place of issue.id. It should work in the validator.

import com.atlassian.jira.Componennt.ComponentAccessor

def allDone = true
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def outwardLinks = issueLinkManager.getOutwardLinks(issue.id)

outwardLinks.each {
if (it.issueLinkType.name == "link outward description") {
def linkedIssue = it.getDestinationObject()
if (!linkedIssue.resolution) {
allDone = false
}
}
}
return allDone

 

Heidi Fernandez
December 18, 2025

The above is getting an error.  It doesn't like issueLinkManager as a def,  I changed it and still cannot compile.

Heidi Fernandez
December 18, 2025

another idea:  currently I have this working but I need it to be the opposite:

currently:  it says a story cannot close until the feature closes.

import com.atlassian.jira.Componennt.ComponentAccessor

ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id.any() {it.issueLinkType.outward == "child of" && it.destinationObject.getIssueType().name == "Feature" && it.destinationObject.resolution}

Need it to be changed to say parent of and look for all links and if any links are not resolved then the parent issue (feature) cannot be transitioned to a resolved state.  Done/OBE/Rejected.  The links of the feature in this case can be stories or tasks.

Heidi Fernandez
December 18, 2025

Appreciate your help!

Heidi Fernandez
December 18, 2025

I am here and it is blocking the feature's transition to done no matter if the linked story is in progress or done.

import com.atlassian.jira.Componennt.ComponentAccessor

ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id.any() {it.issueLinkType.outward == "Parent of" && it.destinationObject.getIssueType().name == "Story" && !it.destinationObject.resolution}

I think maybe the issue is this:  !it.destinationObject.resolution ? 

Trudy Claspill
Community Champion
December 18, 2025

Is that all the code you have in your validator?

Can you provide a screen image that shows the configuration of the validator?

By using it.destinationObject.resolution in your criteria you are looking directly at the Resolution field of the issue, not the Status of the issue. It is possible for the Resolution field to be set even if the Status is one that indicates the issue is not complete.

Does the issue you are testing against actually have any linked issues where the Resolution has been set (ignoring the Status of the linked issue)?

Heidi Fernandez
December 18, 2025

Yes, the issue I am testing does have a resolution of done.  I chose resolution, because there are 3 statuses in our workflow that have resolutions.  I can change it to view status, but would need help with the syntax of contains status done, OBE, and rejected.  I have checked the feature and linked story.  The linked story has a resolution of done.  I am using the simple scripted validator in my feature workflow transitioning to done status.

I checked the script again.  I entered the outward description name vs the name of the issue link,  It works now!!  Thank you so much!  I really appreciate it!

"link outward description" to "parent"
import com.atlassian.jira.Componennt.ComponentAccessor

def allDone = true
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def outwardLinks = issueLinkManager.getOutwardLinks(issue.id)

outwardLinks.each {
if (it.issueLinkType.name == "parent") {
def linkedIssue = it.getDestinationObject()
if (!linkedIssue.resolution) {
allDone = false
}
}
}
return allDone

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.0
TAGS
AUG Leaders

Atlassian Community Events