The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to get key and issue type from linked issue?

NewByatl
Contributor
July 12, 2021

I'm writing script (behaviour) which doing next : If current issue (for example A-1 has linked issue with key CRSUB and issueType Story. Then customField "Def on prod" become avaliable for certain group in project. How i can do it? I have some dificults in writing this script.

 

import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLink;

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject("CR-177")


def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())


def output = ""
for( l in links) {

output = output + l.getDestinationObject() + "<br/>"

if (output.contains("CRSUB") ){
log.warn("test")
}

}

return output

// How to get current issue and issueType of linked issue? Im stuckimage-2021-07-12-15-48-41-176.png

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Nic Brough -Adaptavist-
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 Champions.
July 12, 2021

The iterative object here should be an issue in its own right, so l.getKey() would be a starting point.  You can probably see how to get the rest of the issue information.