Hello Everyone,
We want create a Script Fields (ScriptRunner) that calculates the key of the linked ticket.
Can somebody help me?
Thx!
Solution:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkedIssueKeys = []
for (IssueLink link in ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id)) {
linkedIssueKeys.add(link.getSourceObject().getKey())
}
return linkedIssueKeys
Hi Ruben NV,
You can try and modify this code according to your needs:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
Issue issue = ComponentAccessor.issueManager.getIssueByCurrentKey("SCRUM-13") // get a expecific issue to test the script, comment this line after that.
def linkedIssueKeys = []
for (IssueLink link in ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id)) {
linkedIssueKeys.add(link.getDestinationObject().getKey())
}
return linkedIssueKeys
Regards,
Adrián.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ruben NV,
You need to comment or remove the line 6 if you put the code directly in the script field try this code:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkedIssueKeys = []
for (IssueLink link in ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id)) {
linkedIssueKeys.add(link.getDestinationObject().getKey())
}
return linkedIssueKeys
Regards,
Adrián.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I change the code but need get inward links, and this:
ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.id))
return same issue key.
Thks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Final Code:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def linkedIssueKeys = []
for (IssueLink link in ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.id)) {
linkedIssueKeys.add(link.getSourceObject().getKey())
}
return linkedIssueKeys
Thaks for help@Adrián Plaza [DEISER]
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.