Hi All,

I am struggling with Issue Linking using groovy, I have an Inward Issue Links, So i need to capture that issue link and then using that issue link i need to perform some operations, like setting a status for that associated issue link.So any idea,I have written a piece of code. but its giving me the current issue ID and name.

def public OpenPositionFinalVersion(MutableIssue issue)

    componentManager = ComponentManager.getInstance()
    customFieldManager = componentManager.getCustomFieldManager()
    issueFactory = componentManager.getIssueFactory()
    issueManager =ComponentAccessor.getIssueManager()
    jiraAuthenticationContext = componentManager.getJiraAuthenticationContext()
    issueWorkflowManager = ComponentAccessor.getComponentOfType(IssueWorkflowManager.class);
    issueFactory = ComponentManager.getInstance().getIssueFactory()
    IssueLinkManager linkManager = ComponentManager.getInstance().getIssueLinkManager()
    IssueLinkTypeManager issueLinkTypeManager = (IssueLinkTypeManager) ComponentManager.getComponentInstanceOfType(IssueLinkTypeManager.class)
    IssueIndexManager issueIndexManager =ComponentAccessor.getIssueIndexManager()
    workflowManager = ComponentAccessor.getWorkflowManager();
    issueLinkTypeManager= ComponentManager.getInstance().getIssueLinkManager()

    // This will log the error for this file
    def Category log = Category.getInstance("com.onresolve.jira.groovy.OpenPositionFinalVersion");
    log.warn("Current Issue is : " + issue)
    List<IssueLink> allInIssueLink = linkManager.getInwardLinks(issue.getId());
    for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
        IssueLink issueLink = (IssueLink) inIterator.next();
        log.warn("Issue Link Type is : " +issueLink.getIssueLinkType().getId());
        log.warn("Issue Link Name : " + issueLink.getIssueLinkType().getName())
        Issue issue1= issueLink.getDestinationObject()
    Collection<IssueLinkType> issueLinkTypes = ((IssueLinkTypeManager) ComponentManager
    String linkID=null;
    for (IssueLinkType linktype : issueLinkTypes) {
        String name=linktype.getName();
        if(name.equals("Open Position - Candidate Ticket")){

1 answer

1 vote

I think it might be because links are directional.

Let's say you link issue ABC-123 TO issue ABC-456 with a link type of "depends on". So 123 "depends on" 456, and 456 "is a dependency of" 123. Another way to say it might be "ABC-123" is the "source" and "ABC-456" is the "destination".

So, when your code iterates through the "inward links", it's getting a list of links where the "destination" is the current issue. Asking the link what the destination is, will always return the current issue.

I think you want to look for "source object" instead, for inward links (and destination object on outward links)

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

504 views 1 18
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