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

1 vote
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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,270 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot