Using Scriptrunner, I want to use the workflow condition "Linked issues condition" to transition an issue based on the resolution of linked issues. The problem is that that built-in capability doesn't specific by issue type or by project.
For context, we have Feature issue types in project ABC, that uses link type "derivation". So a Feature can have an inward direction called "derivation is", and that's where all the child issues are under. But our Feature can have that same link type for different issue types and some to different projects.
We want so that if a Feature has derived issue types Story or Spike, within the same project as the Feature, and if those child issues are Done, then the Feature can be done.
I'm trying to use Custom script condition. And this goes under the Feature workflow in project ABC.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueTypes = ["Story","Spike"]
def projectABC = ComponentAccessor.getProjectManager().getProjectObjByKey("ABC")
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def parentLink = "derivation is"
def done = ["Done","OBE"]
for(IssueLink derivedLink in issueLinkManager.getOutwardLinks(issue.id)) {
if (derivedLink.getIssueLinkType().getName() == parentLink) {
def linkedIssue = derivedLink.getSourceObject()
def linkType = linkedIssue.getIssueType().getName()
if(linkedIssue.issueType.name == issueTypes && linkedIssue == projectABC && linkedIssue.getStatus().name != done) {
passesCondition = false
}
}
I tried switch Inward and Outward direction, and tried grouping conditions and still doesn't work. I test it by viewing this:
BEOFRE
Feature-123
>parent link "derivation is"
-Story << not done, so Feature cannot transition to done
-Spike << is done
-Bug << different issue type, so ignore
-Story << under different project, so ignore
AFTER
Feature-123
>parent link "derivation is"
-Story << now is done, so Feature can transition to done
-Spike << is done
-Bug << different issue type, so ignore
-Story << under different project, so ignore