Jira Groovy Script Runner - Clone an issue and link - avoid creating duplicate clones

I'm trying to use the post-function to clone an issue into a separate project and link it. I've put this post-function on the Resolve transition. Our workflow is such that it is not uncommon (maybe 5% of issues) for issues to be Resolved, but Rejected by our test department, which sends them back into In Progress for a developer to work on it, which will then go back through the Resolve transition.

We have a checkbox to indicate whether the change requires that user documentation be updated - only about 5-10% of all issues need documentation updates.

The way we've set this up so far is to have a separate project for the Documentation team, so they can track and manage their issues separately from the rest of development. They also work to a slightly different time schedule than the rest of us.

Basically what is happening now is that if I move an issue through Resolve, then Reject it, and Resolve it again, the 2nd time through I get another clone of the issue created in the documentation project, but what I want is only 1 unique copy to be created.

I figure the easy way to check for this is that if there is any documentation issue linked to the main issue, upon going through Resolve no new clone needs to be made.

Here's the Groovy condition statement I've got, which clearly isn't working:

cfValues['Documentation Required'].value == 'Yes' && issueLinkManager.getOutwardLinks(issue.getId())*.getDestinationObject().getProjectObject().getName().value != 'Documentation'

I've based this off the "Has at least one outward duplicate link" canned example. I expect that the "getOutwardLinks" is returning a collection and I probably need to loop through that, but I don't really know how to do that when making it into a condition to check.

1 answer

1 accepted

This widget could not be displayed.
Henning Tietgens Community Champion Mar 10, 2014

You could write

!issueLinkManager.getOutwardLinks(issue.getId())*.destinationObject.projectObject.name.contains('Documentation')

If you use the *. operator you get a collection of the results of the following 'path' for all elements of the collection. So issueLinkManager.getOutwardLinks(issue.getId())*.destinationObject.projectObject.name contains all names of the projects of the destination issue objects. contains() checks if the element is in the collection and with ! you negate the result of this check.

Exactly... if you use the spread dot operator you need to compare with a list or use "in" or "contains".

This works, thanks!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

52 views 1 0
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