Issue Links validator failing when issues are linked

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

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

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

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. 

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.

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

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 vote

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.

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published Friday in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

50 views 0 3
Read article

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