I need to enable an issue transition based on the status of its linked issues using ScriptRunner.
After reading tons of examples and other forums, it seems this should be straightforward, but I'm getting an error.
Following ScriptRunner's documentation here: https://scriptrunner.adaptavist.com/5.5.9/jira/recipes/workflow/conditions/all-dependent-issues-resolved.html
My steps should be to add a "Script Condition [ScriptRunner]" > "Simple scripted condition" Condition on the Transition workflow step. This condition should look like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkType = ["Blocks"]
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.name)) {
if (!link.sourceObject.resolutionId) {
passesCondition = false
}
}
}
However, I'm getting this error appearing on the passessCondition = false line:
[Static type checking] - The variable [passesCondition] is undeclared at @ line 10, column 7.
Regardless, I've saved and applied the condition. The behavior I'm seeing is the workflow transition does not appear (as expected, initially), but does not become available once I've marked the linked issues "Done" (resolved).
I tried declaring the variable and applying a condition that looks like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkType = ["Blocks"]
def passesCondition = true
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.name)) {
if (!link.sourceObject.resolutionId) {
passesCondition = false
}
}
}
There was no error when I saved the condition, but the workflow behavior was the same: the workflow transition never became available after I closed/marked done/resolved all linked issues that were blockers.
Here's some version information:
JIRA Version 8.2.1
ScriptRunner Version 5.5.9.1-jira8
(We're server-based).
Admittedly, I'm very new to ScriptRunner; would appreciate any help.
Got it working:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkType = ["is blocked by"]
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.inward)) {
if (! link.sourceObject.resolutionId) {
passesCondition = false
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.