There is a method to create a link in script runner.
Is there a method or way to create Inward or Outward link explicitly ? As the inward or outward link name only will be visible to the users (not link name) , we want to create inward or outward link using script.
Create a variable of type com.atlassian.jira.issue.link.IssueLinkManager and then use the createIssueLink() method
The order of the issue IDs you pass as the first 2 arguments dictates the direction.
If you are using a listener or post-function, as @Payne mentioned, you could use the IssueLinkManager to create the issue link.
Below is a sample code for your reference:-
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue
def customFieldManager = ComponentAccessor.customFieldManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def issueManager = ComponentAccessor.issueManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customVersion = customFieldManager.getCustomFieldObjectsByName("Linked Project Versions")[0]
def customVersionValue = issue.getCustomFieldValue(customVersion).toString() as List<String>
def issueIds = issueManager.getIssueIdsForProject(11900)
def issues = issueManager.getIssueObjects(issueIds)
issues.each { sourceIssue ->
def versions = sourceIssue.fixVersions
versions.findAll {version ->
if(version.name in customVersionValue) {
issueLinkManager.createIssueLink(issue.id, sourceIssue.id, 10003, 1, loggedInUser)
}
}
}
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
You will also need to refer to the Issue Linking page as shown below
and move your mouse over the Edit link to get the correct link id to be used as shown in the image below:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.