Script does not return remote link

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

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

303 views 1 4
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