Forums

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

How to check on issuetype and presence of issuelink of "blocks"/ïs blocked by"

Sandra Meessen
Contributor
March 20, 2018

Hello, can you help me on this one? I'm not a very experienced Scriptrunner coder, so I'm a bit lost in all I googled on my question. I need a validation I can put in my workflow for this situation: a Story (Jira issue of issuetype Story) may not be blocked by any other issue (issuelink "blocks"/"is blocked by"), in case the Story needs to be "closed". 

So I have issue Story-A and it's connected to 1 Task-B with issuelink "is followed up by" and it's connected with 1 Task-C with issuelink "is blocked by". So Task-C blocks my Story-A. Task-B contains followup activities. 

So Story-A can only by moved to status "Closed" in case Task-C is also closed. As long as Task-C is active (not closed), it's blocking my Story-A. what is my outward issuelink and my inwars if I say Story-A "is blocked by " Task-C and Task-C "blocks" Story-A?

Thank you and kind regards,

1 answer

0 votes
Tarun Sapra
Community Champion
March 20, 2018

In the validation phase of the workflow transition you can use the issueLinkManager.getOutwardLinks

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/link/IssueLinkManager.html#getOutwardLinks-java.lang.Long-

This will give you all the links, you can traverse over the links using .each {} (groovy closure list.each)

within the closure you can check for the link name using

issueLink.getIssueLinkType().getName() == "<your link name>"

then if it's a match you can check if the "destinationIssue" i.e. task-c is closed or not and if it's not closed then you can throw the exception

throw new InvalidInputException("Task C not closed thus transition can't move ahead on this story")

 

 

If you are not sure about the code, my suggestion is to try it first in script console and for the issue object, you can get an issue using the IssueManager to get an issueObject and play around with the script with proper log messages as that will help you in troubleshooting. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events