Hi there,
Using Scriptrunner for Jira Server, I'm trying to return a number count of linked issues if those linked issues meet certain conditional requirements.
Namely, I'm looking to input a count into a scripted field (one with a Number Field template called "Upsell Count"). This script should only run on "Invoice" issuetypes.
The count should = the number of "Upsell" issues linked to the "Invoice" if the resolutions of the "Upsell" are NOT in ("Declined", "Deprecated").
I'm stuck on the resolution conditioning. Here's what I have so far. Anyone have ideas on how to accomplish what I'm looking for and/or improve what I already have?
import com.atlassian.jira.component.ComponentAccessor
if(issue.issueType.name == "Invoice")
{
int x = 0
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkedIssues = ComponentAccessor.getIssueLinkManager().getLinkCollection(issue, currentUser).getAllIssues()
if (linkedIssues.size() > 0){
for (int i = 0; i < linkedIssues.size(); i++){
if (linkedIssues[i].getIssueType().getName() == "Upsell"){
x = x + 1
}
}
}
if (x > 0){
return x
}else return null
}
Thanks so much! My org is on Jira Server v7.12.3.
Cheers!
With the exact same code, I was able to solve this issue by upgrading to ScriptRunner 6.10.0.
I believe this is related to https://productsupport.adaptavist.com/browse/SRJIRA-4611.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.