Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Checking Linked Issues on duplicates

Hans-Hermann Hunfeld December 17, 2015

Hi all,

i was just to setup a validator to check if resolution is set to "Duplicate" there must be at least one linked issue of type "Duplicate". If the link was created befor the transition is done everything is fine, but in case it´s entered in the same transition screen it´s not working, the system simply ignores the duplicate issue but shows the error message to add a duplicate link.

Checking the according documentation of the Script Runner Plugin it tells me to add some further code, but maybe i don´t put it together right or it´s broken. Here´s our according validator script:

import webwork.action.ActionContext

def request = ActionContext.getRequest()
if (! request) {
    return true // submitted through REST API - we can't do anything about this
}

def linkedIssueKeys = request.getParameterValues("issuelinks-issues")
def linkedIssueType = request.getParameter("issuelinks-linktype")

log.debug("linked issues: " + linkedIssueKeys) // can be null, or a String[]
log.debug("linked issues: " + linkedIssueType) // a String

issue.resolutionObject.name != "Duplicate" ||
     issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('Duplicate')

image2015-12-17 16:40:26.png

Any ideas?

Thanks & regards,
Hans-Hermann

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2015

The documentation doesn't give a complete script, just a guide.

The last line should be something like:

issue.resolutionObject.name != "Duplicate" || ( 
        issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('Duplicate') ||
            (linkedIssueType == "duplicates" && linkedIssueKeys)
    )
Hans-Hermann Hunfeld December 17, 2015

Hi Jamie,

changed my script to

import webwork.action.ActionContext

def request = ActionContext.getRequest()
if (! request) {
    return true // submitted through REST API - we can't do anything about this
}

def linkedIssueKeys = request.getParameterValues("issuelinks-issues")
def linkedIssueType = request.getParameter("issuelinks-linktype")

log.debug("linked issues: " + linkedIssueKeys) // can be null, or a String[]
log.debug("linked issues: " + linkedIssueType) // a String

issue.resolutionObject.name != "Duplicate" || ( 
        issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('Duplicate') ||
            (linkedIssueType == "Duplicate" && linkedIssueKeys)
    )

but still no success!

Currently only one duplicate direction is working (duplicates) in case of adding it before performing the transition, all stuff entered during the transition is ignored...

Sorry, i´m no coder and my collegues didn´t have any ideas so far what might be missing.

Thanks & regards,
Hans-Hermann

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2015

Hi... we'll write a complete script and update the docn, but not immediately. I updated my answer, I had the "linkedIssueType == " wrong. But it depends on the language in your jira. "duplicates" is the name of the outwards link. "Duplicate" in my case is the name of the link type.

0 votes
Hans-Hermann Hunfeld December 18, 2015

Hi all,

thanks Jamie for the right solution, here´s the script which was successfully tested by us:

import webwork.action.ActionContext

def request = ActionContext.getRequest()
if (! request) {
    return true // submitted through REST API - we can't do anything about this
}

def linkedIssueKeys = request.getParameterValues("issuelinks-issues")
def linkedIssueType = request.getParameter("issuelinks-linktype")

log.debug("linked issues: " + linkedIssueKeys) // can be null, or a String[]
log.debug("linked issues: " + linkedIssueType) // a String

issue.resolutionObject.name != "Duplicate" || ( 
        issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('Duplicate') ||
            (linkedIssueType == "duplicates" && linkedIssueKeys)
    )

Many thanks,

Hans-Hermann

 

0 votes
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2015

Hi Hans-Hermann, Do you get any errors in your logs during the validation ? (An easy way to get the logs is to use the built in script View server log files)

TAGS
AUG Leaders

Atlassian Community Events