I am trying to force user to link an issue before they can transition.
Here is the validator I added
Script workflow function : The following fields will require to have their values changed: Linked Issues
It allows me to proceed even though there are no linked issues in the JIRA
Using JIRA 6.1.6 and groovy 2.1.16.
I have also tried "Field has been modified Validator" from JIRA Misc Workflow plugin, and I experience the same result
I've added my own custom Groovy script using ActionContext.getRequest and the functionality meets my requirements. Thanks
Do you need that user make any link or a link of specified type, for example bloked by?
It can be any parent-child link. The workflow is allowing the transition if I have no link at all
Hi Brian,
I have attached an example as shown in the screenshots in the document here which shows how you can add a Simple Scripted Validator to a transition to say the transition can only occur when an issue has one of more linked issues. In the example attached I am blocking the To-Do to In Progress transition when no linked issue is on the issue being transitioned.
The code used for the scripted validator is:
// Issue must have at least one Linked Issue attached to it issueLinkManager.getOutwardLinks(issue.getId()).size() >= 1
If you wish to specify a specific issue type then you can do this using code similar to below for the scripted validator.
// Issue must have a linked issue of the type Duplicate issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')
I hope this helps.
Thanks
Kristian
Thanks Kristian, this will work only if an issue is linked previously. I'd like to force linkage during the transition and have added a transition screen with Linked Issues on it. Unfortunately, since the issue is not linked in the database, it will not recognize the linked issue added in the screen.
I'm guessing there is a bug in my original way to do this?Script workflow function : The following fields will require to have their values changed: Linked Issues
Have you placed yout post function so that it is the last post function in the list and appears below the Re-index an issue to keep indexes in sync with the database post function?
This isn't a post-function. It is a validator
Sample code for this is at https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html#_checking_linked_issues
Yes this works. Thanks Jamie. But I need to point out that this canned script does not work:
Maybe it's a moot point because this is an older version of scriptrunner
It looks like you're new here. Sign in or register to get started.