Hi everyone,
I'm trying to do some condition with script runner.
The goal is showing a transition with à warning (because last tash to go on done status) when all task associated with issue link are done but one (the one i'm making the transition). Else we show a classic transition.
I created 2 differents transitions and fix transition as following (with opposite check in the last bloc for the second transition):
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.issue.link.LinkCollectionImpl;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueInputParametersImpl;
IssueService issueService = ComponentAccessor.getIssueService()
// Récupération de l'ID du PARENT de la tâche
def parentIssueId = issue.getParentObject()?.getId()
log.debug("parent : " + parentIssueId)
// Compteur du nombre TOTAL d'issues enfant du PARENT
def allChildrenIssue = 0
// Comteur du nombre d'issues enfant DEJA passées en DONE
def allChildrenDone = 0
// On itère les enfants du PARENT
List<IssueLink> allOutIssueLink = ComponentAccessor.getIssueLinkManager().getOutwardLinks(parentIssueId);
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
// On récupère l'issue enfant ...
def linkedIssue = issueLink.getDestinationObject()
// ... puis on stocke son statut
String statusOfTheChild = linkedIssue.status.name;
// On incrémente le compteur d'issues ENFANTS
allChildrenIssue ++
// On incrémente le compteur d'issues enfants déjà DONE
if(statusOfTheChild == "Done"){
allChildrenDone ++
}
}
// Si il y a d'autres tâches qui ne sont pas DONE, cette transition est inaccessible
if (allChildrenIssue != (allChildrenDone + 1)){
passesCondition = false;
}
The problem is the condition isn't working. Logs are showing me i get null for the parentIssueId variable...., can't understand why...
I got the feeling it's almost this but i still miss something !
Thanks by advance!