Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Collect every linked issue and check their status

Vladimír Rahm October 28, 2014

Hi,

I want to check if all linked issues are closed, but its not working... Don't know why.

It's created in Misc workflow extensions as post-function.

Thank you for any advice.

My script:

When I do any action, there is debug output like "Unable to find field 'id'"

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.ManagerFactory
//import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.link.IssueLinkImpl

def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def closedIssues = true;

issueLinkManager.getInwardLinks(linkedIssue.id).each {issueLink ->
  if (!(issueLink.getStatusObject().getName().toUpperCase() == "CLOSED")){
    closedIssues = false;
    //break;
  }
}

return closedIssues;

 

I also tried it with "issue.id" instead of "linkedIssue.id"... Same response.

 

This is "help" from post-function script editor:

  • issue: a simple wrapper around the Issue object. Use issue.get("<fieldname>") to get the value of a field
  • issueObject: the Issue object itself
  • linkedIssue: a wrapper around the linked Issue to transition
  • linkedIssueObject: the linked Issue to transition
  • log: a Logger instance that writes into atlassian-jira.log (useful for debugging)

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Guilherme Nogueira
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.
January 22, 2015

Maybe you need to use "issueObject" isntead issue. Im using that:

 

import com.atlassian.jira.ComponentManager
import org.apache.log4j.Category
import com.atlassian.jira.issue.link.IssueLink;
import com.opensymphony.workflow.InvalidInputException
 
log = Category.getInstance("com.onresolve.jira.groovy.LinkedIssues")
log.warn("issue key: " + issue.key) 
passesCondition = true
 
testlinkType = ["Relates"] //your issue link type
 
linkMgr = ComponentManager.getInstance().getIssueLinkManager()

for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
 
    log.warn("linked issue type: " + link.issueLinkType.name)
    log.warn("linked issue key: " + link.getSourceObject().getKey())
    log.warn("linked issue status (name): " + link.getSourceObject().getStatusObject().getName())
    log.warn("linked issue status (id): " + link.getSourceObject().getStatusObject().getId())
 
    if ((testlinkType.contains(link.issueLinkType.name))) //to execute an action if link equals to
    {


    }
}

 

Just work on this code, here you have everything.

Guilherme Nogueira
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.
September 3, 2018

Thank you for the update @Flavio Beck

Like Flavio Beck likes this
Maykel_Oenning July 8, 2019

Doesn't work for Jira 8. Help please

0 votes
Boris Georgiev _Appfire_
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.
October 30, 2014

try linkedIssueObject instead linkedIssue

TAGS
AUG Leaders

Atlassian Community Events