Script does not return remote link

Kevin Seery November 30, 2017

Hi,

Trying to get this script to return link highlighted:

Conf link.JPG

But can only get:

Confluence (5ee79c44-8e2a-3e22-bb7b-63268d5f5764) https://pmo.sure.com/confluence confluence

 

Sorry new to this scripting can someone help?

 

import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.jira.bc.issue.link.RemoteIssueLinkService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import com.atlassian.jira.issue.link.RemoteIssueLinkStore

def applicationLinkService = ComponentAccessor.getComponent(ApplicationLinkService)
def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService)
def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first()

return conf_link

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Thanos Batagiannis _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 Leaders.
December 5, 2017

Hey Kevin, 

For remote links to an issue you have to make use of theRemoteIssueLinkManager. So for example if you want to get all the remote links (from your script console) for issue with key ATG-12 and print the application they are coming from, their title and their URL your script will look like 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("ATG-12")
def remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
def remoteLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)?.collect {"From Application ${it.applicationName}, Title ${it.title}, URL: ${it.url}"}?.join("<br>")

log.debug "Remote Links are $remoteLinks"

Hope that helps,

Thanos

Cassio Miranda May 31, 2019

Hey @Thanos Batagiannis _Adaptavist_ , 

Is it possible to set the variable remoteLinks above into a customfield through updateValue or setCustomField ? 

Could you give me some help please ?

Thanks.

 

Cassio.

TAGS
AUG Leaders

Atlassian Community Events