Forums

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

Groovy: How to get the status of link issue?

Thao Nguyen Thi Thu October 28, 2020

Hi everybody,

I'm new to Script. I'm working on post function, I create/clone Issue and in Condition execution, I want to return True value with condition: If the status of linked issue == "Closed".  I have script as below: issue.getLinkedIssues("relates to").status.name.toString() == "Closed"

But It does not work well. So How can I get the status of link issue? 

1 answer

1 accepted

1 vote
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2020

hi @Thao Nguyen Thi Thu welcome on the community :)

I think the problem here is that issue.getLinkedIssues method does not exist.

You should use something like:

def linkedIssue;
List<IssueLink> outwardLinks = issueLinkManager.getOutwardLinks(issue.getId())
.stream()
.filter({ linkName == "relates to" })
.collect(Collectors.toList())
if (outwardLinks.size() > 0) {
linkedIssue = outwardLinks.get(0).destinationObject
}

if(!linkedIssue){
List<IssueLink> outwardLinks = issueLinkManager.getInwardLinks(issue.getId())
.stream()
.filter({ linkName == "relates to" })
.collect(Collectors.toList())
if (outwardLinks.size() > 0) {
linkedIssue = outwardLinks.get(0).destinationObject
}
}

if(linkedIssue){
return linkedIssue.status.name == "Closed"
}
return true //returning True because there is no issue linked with link type "relates to"
Thao Nguyen Thi Thu November 1, 2020

Thank you a lot Martin Bayer, It's ok for this post function.

Suggest an answer

Log in or Sign up to answer