jira close as duplicate if linked as duplicate

Hi all,

I have found a way through a grovvy script to make sure when the close with resolution = duplicate that they have an issue linked with outward as duplicate.  

The problem I am having is that the user can still link an issue as duplicate, and it not be closed. 

To do this I go into "More" => Link, and then link as duplicate.  

My user wants to only be able to link as duplicate when closing as duplicate.  Is that possible?   

Here is my verification script that works on the close transition

linkCnt = 0
 
request = webwork.action.ActionContext.getRequest()
if (request) {
    // check for new duplicates link
    linktype = request.getParameter('issuelinks-linktype')
    linkedIssue = request.getParameter('issuelinks-issues')
    if (linktype == 'duplicates' && linkedIssue) linkCnt = 1
}
 
// check for existing duplicates link
if ( issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate') ) linkCnt += 1
 
// Transition requires one, and only one, duplicates link or the resolution not to be Duplicate
(linkCnt==1) || cfValues['resolution'].toString() != 'Duplicate' 

:

 

2 answers

1 accepted

0 votes
Accepted answer

Actually JIRA does support it as of 4.4 and that is how we are doing it.  (include Linked Issues on the closing screen to accomplish it)   I was hoping to be able (I am sure I could if  I knew js better) hide the link at all time except if I am on the closing screen.  Though we have many teams using JIRA (Legal, Marketing, etc) and this request is just coming from Engineering.

I guess the real question is now, "How can I search for linked issues", and the answer is JQL tricks plugin allows it.

But do they support deleting the link if the close operation doesn't work?  And not being able to use that link type elsewhere?

No ,but that is not what I need.  I only need to:

  1. Only allow a resolution to be closed with duplicate if you have an issue linked with duplicate.  The code above.
  2. prevent people from link with duplicate and not closing the issue

    For that one I will create a JQL query to find any non closed issues with a Duplicate link and email (subscribe) that report and that way I am not prevented it but I can slap those on the wrist that do fail to close duplicates.  To do that I believe I will need to install JQL tricks, but that is free so no need for finance (finance is not a fun process for me)

 

Ugh JQL tricks is not free bummer.  Anyone know how to find all issues that have a duplicate link?    I bet I could with the CLI...  hmm...

Can you use that in a JQL filter?  Above I have the Script runner validator code already.  I need to create a filter to find anyone who has created a link as Duplicate yet did not close the issue.

Actually it does WOW  thanks Learnt something knew smile

issueFunction in hasLinks('duplicates') 

The best I can think of would be to also disallow closing as anything except Duplicate, if there is an outward duplicate link.  As in, augment your existing validator to something like:

(linkCnt==1 && cfValues['resolution'].toString() == 'Duplicate') || (linkCnt==0 && cfValues['resolution'].toString() != 'Duplicate')

That way if linkCnt is > 1, or the resolution doesn't match the linkCnt, they won't be able to close.

But that would still allow an issue to have a duplicate link but not be closed.

Even if I could have a filter that people could subscribe to that would have any issue that has a duplicate link and is not resolved that would work, but I prefer to prevent this behavior completely.

So I do not want people to link as duplicate without closing the issue.

Unfortunately, I can think of no way to do that, unless linking emits an event you can use to trigger a script listener; even then, the listener would have to unlink it, and so the user would not know there was an issue, or close it, which it may not have the context to do. Unless there is a way to disallow linking entirely based on the status, and only allow linking post closure, but then you wouldn't be able to link anything.

I suppose there is likely a javascript option available that could filter the list of available link types.

Fundamentally, this is a chicken/egg scenario.  You can't have it require that it be closed-as-duplicate before linking as duplicate, and also be linked-as-duplicate prior to closing-as-duplicate, that's a circular dependency.  If you could do both at the same time, in the same 'transaction', that would work, conceptually, but it means you have to perform the link (actually, a pending link) in the Close transition, which JIRA doesn't support to my knowledge.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Friday in Jira Service Desk

Looking for anyone who has switched from Zendesk to Jira Service Desk

Hi Community! The Jira Service Desk marketing team is looking for customers who have successfully switched from Zendesk to Jira Service Desk!   We’d love to hear your thoughts on the pros and ...

117 views 7 3
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