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 Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

149 views 1 17
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