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

1 vote
Accepted answer

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
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

412 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