Script runner -- questions about issue link validation within workflow transitions.

Hi all,

Had a couple questions with script runner. I know (and use) transition validation scripts like the example below:


..but how can I require that the link also be limited to a specific issue type? Such as 'Bug'?

My other question is that I've noticed that the transition validation example above works fine if the link is set earlier in the workflow. *However* -- if the transition that has the validation script also has a transition screen with an issue link field, and the user uses that field, the validation script doesn't notice it, and prevents progression in the workflow. Ideally I'd like to make it so the user can add the required field if necessary with in the transition screen itself without backing out and trying the transition again.

Would the solution be to set up a behavior? Guessing I could use same validation script above?

Any tips appreciated!!

1 answer

You can get the issuetype of the linked issue like this

issueLink is one entry of the list you get from getOutwardLinks().

For your second question look here:


How to validate a confluence link? 

Not sure what you mean by "validate", but you can get those links via the RemoteIssueLinkService. E.g.

remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks

to get all remote issue links of an issue.


I want to check at least one confluence page is linked to an issue wiki page link.png

If you know the pageid of the Confluence page (–> select Page Information menu item and take a look at the URL) you could use following method.

boolean hasRemoteConfluenceLink(ApplicationUser user, Issue issue, String pageId, Logger log = null) {
    def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first()
    if (!conf_link) {
        log?.error "No confluence application link found."
        return false
    def globalId = "appId=$$pageId"
    return remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks?.globalId?.contains(globalId)


Thank a lot for response, 

But I want a global script just asking for a link of confluence or web link.

Is there any other way like below script... so that it throws an error and should ask for the link.

because we just can't do every confluence page id and keep on updating the script.



Yes, if you take a look into the API you could see there are some methods to get information from a RemoteIssueLink, e.g. getApplicationType() which should return "com.atlassian.confluence" (or better RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE) for confluence links. Using this the method from above could be adapted to check for any Confluence link.

import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
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)

(Not tested, take care of this by yourself. Please be aware that this takes the current user into consideration and what this user is able to see.)




I'm trying to find a script that returns the a confluence link if contain 'closure report'.

Could this script be adapted todo this?


Many Thanks


Suggest an answer

Log in or Sign up to answer
Community showcase
Published 13 hours ago in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

87 views 3 3
Read article

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