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())*.issueLinkType.name.contains('Dependents'||'null')|| ! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name == ('Blocks')|| ! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name == ('Cloners')|| ! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name == ('Duplicate')|| ! issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name == ('Relates')
@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"]
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: https://scriptrunner.adaptavist.com/4.2.0.2/jira/recipes/workflow/validators/simple-scripted-validators.html#_checking_linked_issues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Couldn't make that work, unfortunately. @Jamie Echlin [Adaptavist]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not tested but will be something like:
def links = issueLinkManager.getOutwardLinks(issue.getId()) !links || links*.issueLinkType*.name.unique() == ["Blocks"]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.