Validate a Confluence Link During Transition

How to validate a link (a confluence link, Wiki Page) to transition an issue.

[I mean I just to check a wiki page, issue should not go to next state without a confluence link]

any chance by using scriptRunner

Thanks 

Dave

3 answers

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
 
static boolean hasAnyRemoteConfluenceLink(ApplicationUser user, Issue issue, Logger log = null) {
    def applicationLinkService = ComponentAccessor.getComponent(ApplicationLinkService)
    def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService)
    def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first()
    if (!conf_link) {
        log?.error "No confluence application link found."
        return false
    }
    return remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks?.any{it.applicationType == RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE}
}
 
hasAnyRemoteConfluenceLink(ComponentAccessor.jiraAuthenticationContext?.loggedInUser, issue)

What exactly do you want to validate? Response from Confluence or that it's a link?

I want to verify that at least one confluence page is linked.

wiki page link.png

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot