Issue Links validator failing when issues are linked

Nicole Murphy February 4, 2016

I've used the following code to try to validate that there is a certain link type when a custom field has a certain value. It is failing whether I create the link before the transition or when I try to link during the transition. I've used the link name, in inward link name, and the outward link name. Nothing successful. Any suggestions?

if (cfValues['Implementing Standard Fields']?.value == "Yes") {
    return issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Implementation')
}
else {
    return true
}

3 answers

0 votes
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.
February 8, 2016

Remove the cf validation for the time being and check the linking works. What you have looks correct but for clarity use:

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
issueLinkManager.getOutwardLinks(issue.getId()).any {
    it.issueLinkType.name == 'Implementation'
}

If that doesn't work can you post a screenshot of your Issue Linking config page.

That won't work for issues added this transition, for that see https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html#_checking_linked_issues.

0 votes
Jeremy Gaudet
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.
February 4, 2016

I have two ideas offhand.  The first is, is "Implementation" part of the actual link "Name", or is it just part of the outward/inward link description?

The second thought is, does the custom field portion of the validator work if you return false?  As in:

if (cfValues['Implementing Standard Fields']?.value == "Yes") {
    return false
}
else {
    return true
}

That's how I normally narrow down the area of failure.  What type of custom field is that?  If it's not a string field, you may need to compare to a boolean, for example.

0 votes
Vasiliy Zverev
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.
February 4, 2016

I am not sure for groovy sintax, but for Java it should be:

cfValues['Implementing Standard Fields']?.value.equals("Yes")

Nicole Murphy February 4, 2016

I don't think the if statement is my problem. When I choose, "No" it let's me pass through. It's when I choose yes, that it's not recognizing the issue link. 

Vasiliy Zverev
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.
February 4, 2016

Ok, second idea: there outward and inward links. Are you sure that you try to get correct one.

Third: issueLinkManager.getOutwardLinks return issue list. I am not sure of groovy sintax, but there should be some loop.

Nicole Murphy February 4, 2016

I've tried pretty much every combination of outward and inward

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events