We have a scripted PE Date - This scripted field displays the farthest Due Date (JIRA FIELD) value from the Child Epic of the Program Epic Issue type.
Now, we want to have the regular Due Date field at the Program Epic issue type screen, and this Due Date must simply display whatever value the PE Date (Scripted field) is displaying without being editable.
Also, The scripted field works on the logic that it displays the most farthest date from the Epic DD values and , when an Epic associated with the Program Epic does not have a Due value, then the scripted field returns a null value.
Hi @Aisha M ,
As I understand it you need to set the farthest (i.e. the oldest) of the epics due date on the program epic due date. My advice is to create a script listener on every event that may be triggered when you set the due date on an epic. These events would most probably be Issue created, Issue updated and maybe others if you are updating the due date on a transition (you need to check your workflow post function in that case).
Add this script below. It will check if there is a Program Epic linked to it, and then all its linked epics to retrieve the farthest due date. I have added a few log lines to help debugging if needed.
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.index.IssueIndexingService
import java.sql.Timestamp
log.error("working on issue : " + issue)
if (issue.getIssueType().getName() == "Epic"){
log.error("the issue is an Epic")
def programEpic
def allOutIssueLink = new ArrayList<IssueLink>(ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId()))
def allInIssueLink = new ArrayList<IssueLink>(ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId()))
def issueLinks = allOutIssueLink?.findAll() {it.getDestinationObject().getIssueType().getName() == "Program Epic"}
if (issueLinks.isEmpty()){
issueLinks = allInIssueLink?.findAll() {it.getSourceObject().getIssueType().getName() == "Program Epic"}
if (!issueLinks.isEmpty()){
programEpic = issueLinks[0].getSourceObject()
}
}
else {
programEpic = issueLinks[0].getDestinationObject()
}
if (programEpic){
log.error("found the program epic : " + programEpic)
allOutIssueLink = new ArrayList<IssueLink>(ComponentAccessor.getIssueLinkManager().getOutwardLinks(programEpic.getId()))
issueLinks = allOutIssueLink?.findAll() { (it.getDestinationObject().getIssueType().getName() == "Epic") && (it.getIssueLinkType().getOutward() == "Parent") }
def farthestDate
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
for(IssueLink issueLink : issueLinks){
def dueDate = issueLink.getDestinationObject().getDueDate()
if (dueDate == null){
programEpic.setDueDate(null)
programEpic.store()
issueIndexingService.reIndex(programEpic)
log.error("the due date is null ! ")
return
}
else if (farthestDate == null){
farthestDate = dueDate
}
else if (dueDate?.after(farthestDate)){
farthestDate = dueDate
}
}
programEpic.setDueDate(farthestDate)
programEpic.store()
issueIndexingService.reIndex(programEpic)
log.error("updating due date with value : " + farthestDate)
}
}
@Antoine Berry Works perfectly ! Just had to ensure that the projects that has the PE issue & Epic issue must be enabled on the listener page :) Thank you :)
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.