Prohibit certain links through validator script

I would like to only allow one type of link to be used through a validator and prohibit the other link types. But I also need to allow the transition to occur if there are no links. I've been able to get everything to work except "null." Any help would be appreciated.

 ! issueLinkManager.getOutwardLinks(issue.getId())* == ('Blocks')||
 ! issueLinkManager.getOutwardLinks(issue.getId())* == ('Cloners')||
 ! issueLinkManager.getOutwardLinks(issue.getId())* == ('Duplicate')||
 ! issueLinkManager.getOutwardLinks(issue.getId())* == ('Relates')

6 answers

This widget could not be displayed.

Not tested but will be something like:

def links = issueLinkManager.getOutwardLinks(issue.getId())
!links || links*.issueLinkType*.name.unique() == ["Blocks"]
This widget could not be displayed.

Couldn't make that work, unfortunately. @Jamie Echlin [Adaptavist]

This widget could not be displayed.

Describe in English how it should work, ie, no links, or what link type? Then test the two parts of the OR separately.

Also can you tell us how it's not working.

This widget could not be displayed.

@Jamie Echlin [Adaptavist] We need the "Dependents" link to be the only link allowed to pass the validator OR no link to also pass.


I'll also need to specify certain links allowed for certain issue types but that's secondary to this.

This widget could not be displayed.

Should work fine. Are the links being modified on the screen for the action that the validator happens in? If so that doesn't work, due to a JIRA "design failure"... There is a possible workaround here:

This widget could not be displayed.

@Jamie Echlin [Adaptavist] - The scenario you just described is exactly what we are trying to accomplish. I tried the workaround you suggested but it's giving the same result as before.


import webwork.action.ActionContext
def request = ActionContext.getRequest()
if (! request) {
    return true 
def linkedIssueKeys = request.getParameterValues("issuelinks-issues")
def linkedIssueType = request.getParameter("issuelinks-linktype")
log.debug("linked issues: " + linkedIssueKeys) // can be null, or a String[]
log.debug("linked issues: " + linkedIssueType) // a String

def links = issueLinkManager.getOutwardLinks(issue.getId())
links*.issueLinkType*.name.unique() == ["Dependents"]

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...

176 views 1 3
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