Need help with Scriptrunner script for working on ONLY one type of issue linking

Aisha M May 12, 2020

I use the below script to capture the dates of the Epic Due Date and display the farthest date at the Program Epic Due Date field (scripted field). If any of the Due Date in the Epic is empty, then the scripted field at the Program Epic returns empty.

The script is working fine, but considers ALL of the epics associated with the Program Epic. Can you please help me modify the script so that ONLY the child of the Program Epic is considered and no other links.

 

import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
import java.sql.Timestamp

def allOutIssueLink = new ArrayList<IssueLink>(ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId()))
def issueLinks = allOutIssueLink?.findAll() {it.getDestinationObject().getIssueType().getName() == "Epic"}
def farthestDate


for(IssueLink issueLink : issueLinks){
def dueDate = issueLink.getDestinationObject().getDueDate()
if (dueDate == null){
return null
}
else if (farthestDate == null){
farthestDate = dueDate
}
else if (dueDate?.after(farthestDate)){
farthestDate = dueDate
}
}

def allInIssueLink = new ArrayList<IssueLink>(ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId()));
issueLinks = allInIssueLink?.findAll() {it.getSourceObject().getIssueType().getName() == "Epic"}

for(IssueLink issueLink : issueLinks){
def dueDate = issueLink.getSourceObject().getDueDate()

if (dueDate == null){
return null
}
else if (farthestDate == null){
farthestDate = dueDate
}
else if (dueDate?.after(farthestDate)){
farthestDate = dueDate
}
}

return farthestDate

 

 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Aisha M May 14, 2020

@Ravi Sagar _Sparxsys_  Hi Sir, Can you please help me with the Scriptrunner script.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events