Adding Validation with issue links

Matthew Shafran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 25, 2017

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
Answer accepted
Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2017

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
}
Matthew Shafran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2017

Hi Daniel,

 

Thanks, that worked!

Daniel Yelamos [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2017

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
TAGS
AUG Leaders

Atlassian Community Events