Hi All,
Can you help me out in auto-transition of parent issue to closed when all its linked issues are closed within the same project. (Adaptavist Scriptrunner)
waiting for an early reply.
thanks
Harish Kumar
Hello @Harish Kumar,
Scriptrunner provides a build-in post-function to do this.
Create a post-function on the transition to close in every subtask workflow. Select "Script Post-Function [ScriptRunner]" then "Transition parent when all subtasks are resolved".
This will look at the resolution of every subtasks of the parent, if all subtasks have a resolution it will make the transition.
Regards,
Adrien
@SITTER Adrien , My query is related to linked issues, not for subtasks...
Sorry I read parent and in my mind I stucked with subtask.
You can use this script: https://library.adaptavist.com/entity/close-an-epic-when-all-the-issues-under-that-epic-are-closed
You should change:
You should put this script as a custom post-function of closing transition on every worfklow of issue that can be linked by the issueLinkName link type.
@SITTER Adrien Hi, I have edited the code, and the final code looks like this:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.workflow.TransitionOptions
// the name of the action you want to move the issue tofinal String actionName = "Closed"
// the name of the issue linkfinal String issueLinkName = "Cloners"
def workflow = ComponentAccessor.workflowManager.getWorkflow(issue)def actionId = workflow.allActions.findByName(actionName)?.iddef issueLinkManager = ComponentAccessor.issueLinkManager
def epicIssue = issueLinkManager.getInwardLinks(issue.id).find { it.issueLinkType.name == issueLinkName }?.sourceObjectif (!epicIssue) {return}
// Find all the linked - with the "Epic-Story Link" link - issues that their status is not completeddef linkedIssues = issueLinkManager.getOutwardLinks(epicIssue.id).findAll { it.issueLinkType.name == issueLinkName }*.destinationObject?.findAll { it.status.statusCategory.name != "Closed" }
// If there are still open linked issues (except the one in transition) - then do nothingif (linkedIssues - issue) {return}
def issueService = ComponentAccessor.issueServicedef issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("This Issue closed automatically because all the linked-issues in this Issue are closed.")issueInputParameters.setSkipScreenCheck(true)
def transitionOptions = new TransitionOptions.Builder().skipConditions().skipPermissions().skipValidators().build()
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef transitionValidationResult = issueService.validateTransition(loggedInUser, epicIssue.id, actionId, issueInputParameters, transitionOptions)assert transitionValidationResult.isValid() : transitionValidationResult.errorCollection
def result = issueService.transition(loggedInUser, transitionValidationResult)assert result.isValid() : result.errorCollection
Query : I need to put this code in the workflow transition of all linked issues and parent issues where the final status is there ? can you explain me please.
Thanks
HArish
Hi @SITTER Adrien , will you please help me too?
I try to make the same process work in Service Desk type project. The status categories there are "To Do", "In Progress", "Done". I changed the code you provided for my case, but it didn't work, will you please have a look and tell me the reason?
// the name of the action you want to move the issue tofinal String actionName = "Resolved"
// the name of the issue linkfinal String issueLinkName = "Problem/Incident"
// Find all the linked - with the "Epic-Story Link" link - issues that their status is not completeddef linkedIssues = issueLinkManager.getOutwardLinks(epicIssue.id).findAll { it.issueLinkType.name == issueLinkName }*.destinationObject?.findAll { it.status.statusCategory.name != "Done" }
It looks like you're new here. Sign in or register to get started.