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

This widget could not be displayed.
Vasiliy Zverev Community Champion Feb 04, 2016

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. 

Vasiliy Zverev Community Champion Feb 04, 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.

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

This widget could not be displayed.

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.

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

176 views 1 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