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.
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.
Google Gemini provided this information:
Disclaimer: I don't have a data center environment with Scriptrunner where I can test this.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I created this and it isn't quite right. What is missing?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What results are you getting?
Have you tried testing the code through the ScriptRunner console and adding statements to show output in the console?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It allows the transition no matter what the status is of the linked issues are. I will try adding statements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The above is getting an error. It doesn't like issueLinkManager as a def, I changed it and still cannot compile.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.