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
@Manoj Gangwar posting an answer to your own question asking for help from someone in particular can be counterproductive. At least for me, I generally have a filter that only shows me questions without replies. So your question was hidden.
Also, taking some time to properly format your code and detailing your problem with full context will remove guesswork and additional work on our part.
As it is, it's not clear where this script will be used and what you want it to do.
Should the script be applicable when the current issue is NOT a subtask?
When dealing with issue linking, it helps to have all the information regarding that link type.: the full name, the inward description, and the outward description.
The filter issueLinkType.name == 'is part of' may not work because 'is part of' is not the name of the link type, but rather either the inward or the outward description.
Also, are you certain the link directions are always going to be inward?
Do you have existing configurations (one or many) in JWT that currently meet both requirements? Maybe include screenshots that show all the details.
Are the issues from both requirements using a shared workflow? Or 2 different workflows?
Based on the limited supplied information, I think maybe you will need 2 or more separate scriptrunner configurations.
If you can confirm some of the additional details, I can suggest some script examples.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.