Adding Validation with issue links

Hey guys,

 

I have been trying to create some validation based on a custom property drop down and issue links. So far, the custom property portion works fine, but the issue links part never seems to work. I have tried some of the different examples on the wiki without much luck. I am trying to make something similar to the code below.

 

cfValues['Test dropdown']?.value != "team 1" || (cfValues['Test dropdown']?.value == "team 1" && has at least 1 linked issue))

 The has at least 1 linked issue has not been working for me. I have tried different options such as:

issueLinkingValue.linkedIssues.size() > 0

ComponentAccessor.getIssueLinkManager().getIssueLinks(issue.getId()

ComponentAccessor.getIssueLinkManager().getIssueLinks(issue.getId().size()

 

Anyone have any suggestions on how I can implement the linked issue portion? 

Note: Using a Simple Scripted Validator from the ScriptRunner plugin.

 

Thanks,

Matthew Shafran

1 answer

1 accepted

Hi Matthew.

For awhile now, links have been divided in two categories.

OutwardLinks, for links that were created from outside the issue.

InwardLinks, for links that were created from inside the issue.

In order to get each you could do this:

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def inwardLinks = issueLinkManager.getInwardLinks(issue.id)
def outwardLinks = issueLinkManager.getOutwardLinks(issue.id)

if(inwardLinks.size() + outwardLinks > 0){
///your code goes here
}

Hi Daniel,

 

Thanks, that worked!

Hi Matthew, glad that was the case. 

Would you mind accepting my answer? That way other people know that this is correct by looking at the title, and you won't get annoying emails saying you have unaccepted questions.

Cheers!

Dyelamos

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

130 views 0 4
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