prevent open tasks from being closed when linked with blocker task

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

Something like this:

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

Works! Thanks a lot!

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

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

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

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

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

is blocked by.png

Hi Ratna

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

Unbenannt.PNG

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

71 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you