Hi,
Im trying to add a validator on a transition to check that an issue link is present for a blocking issue and having no luck.
I used the provided example from the adaptivist site:
import com.atlassian.jira.component.ComponentAccessor ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('duplicate')
and changed duplicate to both 'block' and 'Block' and neither of them work.
I then added a duplicate link to my test issue and used the provided 'duplicate' and it is still not working.
I also tried to add a log.info entry to get some info and logging is not showing up when I go back after the transition to look for logging that is supposed to show when viewing the transition entry in the workflow and logging is not working either.
To test the validator is working at all I added another validator to check that the currentuser must be the reporter and that worked.
what am I doing wrong?
Any help is greatly appreciated.
Hello @Greg Bailey
do you check like this?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueManager = ComponentAccessor.getIssueManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> allOutIssueLink = issueLinkManager.getOutwardLinks(issue.id)
ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('duplicate')
Best regards
Nope hadn't tried that, I had been using the code I posted above. Also, I should have been clearer, Im using the 'Script Validator [ScriptRunner]' Validator ' for the transition. And it already has a number of bindings in place. And their offered code snippet to use for this type of check isn't working.
I did try your suggestion and due to the existing binding I had to tweak one line, but it still does not work.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def issueManager = ComponentAccessor.getIssueManager()
# issueLinkManager is already bound so I just changed your code to a unique value.
def MyissueLinkManager = ComponentAccessor.getIssueLinkManager()
List<IssueLink> allOutIssueLink = MyissueLinkManager.getOutwardLinks(issue.id)
ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('duplicate')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Greg Bailey ,
add this code that I sent you inside condition of 'Script Validator [ScriptRunner]' Validator '
actually this is a condition. The last line checks the condition and return true or false.
if you are using the option of:
If the script returns a falsey value the transition will be blocked with the error message you provide. See the examples above, or the documentation for further information
add a if like
if (ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('duplicate')) {
return false
}
else
{
return true
}
Remember that the best way to use a validator is adding it in a transition screen with the custom field that you are "blocking". If you don't have a transition screen in the transition, the software lunch an error but the transition is blocked also.
Best regards.
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.