I need your assistance to create or modify script for the below requirements:
1- I want to Done the Linked Issue of the current Issue, where Inward issue link types: is part of. AND Linked Issue Type: CDU Delivery AND
expression is satisfied:
count(linkedIssues("parts", linkedIssues("is part of"))) = count(filterByPredicate(linkedIssues("parts", linkedIssues("is part of")),^%{Resolution} != null)) and count(subtasks(linkedIssues("is part of"))) = count(filterByPredicate(subtasks(linkedIssues("is part of")),^%{Resolution} != null))
2- I want to Done the Parent Issue of the current issue when its all Sub-tasks and Related issues are Closed. I have a script but its only satisfying Sub-tasks condition.
Previously JWT plugin expression was below which I want to migrate to Scriptrunner.
expression is satisfied: %{Parent's issue type} = "CDU Delivery" and count(siblingSubtasks()) = count(filterByStatus(siblingSubtasks(), "Done")) and count(linkedIssues("is part of", %{Parent's issue key})) = count(filterByStatus(linkedIssues("parts", %{Parent's issue key}), "Done, Resolved, Closed"))
ScriptRunner Script: Its not satisfying linked issue
import com.atlassian.jira.component.ComponentAccessor // Retrieve the parent issue type def parentIssueType = issue.parentObject?.issueType?.name // Retrieve all subtasks of the parent issue def subtaskManager = ComponentAccessor.getSubTaskManager() def subtasks = subtaskManager.getSubTaskObjects(issue.parentObject) // Count the number of subtasks that are in "Done" status def doneSubtasksCount = subtasks.count { it.status?.name == "Done" } // Retrieve all linked issues of type "is part of" for the parent issue def linkedIssuesParts = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.parentObject.id)?.findAll { it.issueLinkType.name == "is part of" }?.collect { it.sourceObject } // Count the number of linked issues that are in "Done", "Resolved", or "Closed" status def doneLinkedIssuesCount = linkedIssuesParts.count { it.status?.name in ["Done", "Resolved", "Closed"] } // Check if all conditions are met def isConditionMet = parentIssueType == "CDU Delivery" && doneSubtasksCount == subtasks.size() && doneLinkedIssuesCount == linkedIssuesParts.size() return isConditionMet