How to check if inward linked issue type is "Doc Needed"

Hi,

I am trying to setup a listener using groovy-script-listener, it will listen to a custom field value. Setting the value to "yes" will trigger the "clone an issue and links" function.

It will clone the current issue wiith an inward link and set the issue type to "Doc Needed".

My question is how to check if there is an existing "Doc Needed" ticket linked to the affected ticket?

Any help will be apprieciated.

So far I have the following:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor


def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def hasDocType = issueLinkManager.getInwardLinks(issue.id).any{it.destinationObject.issueTypeObject.name == "Doc Needed"} 

log.warn("#######  hasDocType is :" + hasDocType + " &&&&& issue.key  &&&&&:  " + issue.key + "   ##################")

1 answer

1 accepted

Hey Sam,

Here is some Java code that might help.

Collection<IssueLink> links = issueLinkManager.getInwardLinks(issue.getId());
for(IssueLink link:links){
    if(link.getSourceObject().getIssueTypeObject().getName().equals("Doc Needed"))
        //Do Something
}

Hi Bhushan,

Cool, thank for the help. It works when I switched from destinationObject to sourceObject.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

103 views 0 2
Join discussion

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