prevent open tasks from being closed when linked with blocker task

PFS August 7, 2016

Hi

I recently was looking for a way to prevent open tasks from being closed when they are being blocked by other tasks and saw this example.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
 
def issueLinkManager = ComponentAccessor.getComponent(IssueLinkManager)
 
! issueLinkManager.getInwardLinks(issue.getId()).any {
    it.issueLinkType.name == "Blocker"
}

I've added the code as a validator into the closing step of our workflow. This works great so far. However, when the blocker is resolved and closed, we're not able to close the main task.

How can I connect this example with checking whether the blocker is resolved or not?

Thanks for your help.

1 answer

1 accepted

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 7, 2016

Something like this:

! issueLinkManager.getInwardLinks(issue.getId()).any {
    it.issueLinkType.name == "Blocker" && ! it.sourceObject.resolution
}
PFS August 7, 2016

Works! Thanks a lot!

Ratna Kumar Lekkala June 21, 2017

It's throwing error at &&

how do I resolve this?

Both my workflows (parent and linked issues) have Done state as the green (resolved group one?) state last one

Deleted user June 22, 2017

Hi Ratna

It seems like the formatting got messed up. It should look like this.

! issueLinkManager.getInwardLinks(issue.getId()).any {
    it.issueLinkType.name == "Blocker" && ! it.sourceObject.resolution
}

BR

Ratna Kumar Lekkala June 22, 2017

Its still not working for me :(

Should it be "is blocked by" or "blocks" (those are the types I see under issue links). I tried both and it still lets me close the item. I added the code into the simple scripted validator option as shown

simple scripted validator.png

Deleted user June 22, 2017

Hi Ratna

Neither of those will work. You have to use the name of your link. For me, that was Blocker.

Please check under Issue Links what it says under the column Name. It should be the first column.

BR

Ratna Kumar Lekkala June 22, 2017

It should be "is blocked by" for me correct? It does not work

is blocked by.png

Deleted user June 23, 2017

Hi Ratna

No, that's just your inward description. Please check the column Name in your settings under issue links.

Unbenannt.PNG

Ratna Kumar Lekkala June 23, 2017

Thanks! I got it right now!! I was using the description showing on the issue instead of the actual name of the link type fro admin panel.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events