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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.