Problem:
Prevent the workflow transition "Done" from showing up if there are any "is blocked by" linked issues that are not "Done"
Scenarios:
In this scenario, I DO NOT want to see an option to move the Story A status to "done"
In this scenario, I DO want to see an option to move the Story A status to "done"
Attempted Solution:
In the workflow, I've added a scripted condition, however the "Done" status is still an option for the user and I'm able to complete the "Done" transition.
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.name)) {
if (! link.sourceObject.resolutionId) {
passesCondition = false
}
}
}
I used this link as my reference. https://scriptrunner.adaptavist.com/5.0.2/jira/recipes/workflow/conditions/all-dependent-issues-resolved.html
Any advice ??
I think your error is here:
link.issueLinkType.name
this will return "Blockers" or whatever name you have for the link type. Not the directional name.
For that, you want
link.issueLinkType.inward
So try
if (linkType.contains(link.issueLinkType.inward)) {...}
This should result in the Done button being hidden.
Thanks for the help! Your suggestion worked like a charm!
The final...
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.
Came across the same issue, can this be done via new Automation? If yes how?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes. It can be done with automation, but there is something that you need to consider. For this rule to work with automation, must be a multi-project rule. Multi-project rules have execution limits according to your suscription plan. If you are on a standard plan, you only have 1.000 executions, and this rule will be executed every time a issue is resolved.
The rule would be something like this:
Clic here for more information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How does your automation "Prevent Workflow Transition to Done" if it's executed after the issue has already been resolved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is the same possible without script runner add-on?
Or can I add a condition using jql instead of the pre-canned options?
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.