Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner: Validator for "is blocked by" linked issue

MiskaT July 30, 2019

Hello Guys,

I'm trying to block a Status while it has an linked issue "is blocked by". I already tried out several solutions, but otherwise nothing happens or the status is always blocked even if there aren't any linked issues.

 

Maybe on top it would be nice if I can even check the linked issue if it's not approved yet.

 

2 answers

1 accepted

0 votes
Answer accepted
Tom _Automation Consultants_
Atlassian Partner
July 30, 2019 edited

If you visit the {Jira Base URL}/secure/admin/ViewLinkTypes!default.jspa

And click on the Blocks edit button in the URL will have the ID of the Blocks IssueLink (mine was 10000)

Then in the Scripted Validator add the following code to a Simple scripted validator (in the condition section): 

import com.atlassian.jira.component.ComponentAccessor

def BLOCKED_BY_LINKID = 10000

def issueManager = ComponentAccessor.getIssueManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def links = issueLinkManager.getInwardLinks(issue.getId())

def linkedIssue

for(def link : links) {
if(link.getLinkTypeId() == BLOCKED_BY_LINKID){

// Have this section if you want to check the "is blocked by" linked issues status
linkedIssue = link.getSourceObject()
if(!linkedIssue.getStatus().getName().equals("Closed")){
return false
}

// If you dont want that extra check then return false and remove the above if
return false

}
}

return true
MiskaT July 31, 2019

Perfect that's exactly the solution I'm looking for.

Thanks a lot

0 votes
jiraKappa July 30, 2019

Hi!

You mean you are trying to block all transitions from the current issue status to that Status?

Depending if the issue has linked issues?

If that's the case you' should put a script condition in every transtion you want block.

https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/scripted-conditions.html

MiskaT July 31, 2019

Thx for the link and your reply.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events