You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

1

Transition the Original Issue According to the Cloned Issue

Overview

Creates an automation to transition an issue, based on the status of it's cloned issue.

Example

If a cloned issue transitions to Done, the original issue will also automatically transition to the Done.

Requirements

  • Jira Jira (8.0 - 8.18)
  • ScriptRunner for Jira ScriptRunner for Jira (6.32.0)
    
import com.atlassian.jira.component.ComponentAccessor def issueLinkManager = ComponentAccessor.issueLinkManager def issueManager = ComponentAccessor.issueManager def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issueService = ComponentAccessor.issueService def clonedIssues = issueLinkManager.getOutwardLinks(issue.id) // The transition id of the status must have a value of type int final int transitionId = 1 def clonedIssueObjects = clonedIssues.findAll { it.issueLinkType.name == 'Cloners' }.collect { issueManager.getIssueObject(it.destinationId) } clonedIssueObjects.each { def outerIssue = issueManager.getIssueObject(it.toString()) def transitionValidationResult = issueService.validateTransition(loggedInUser, outerIssue.id, transitionId, issueService.newIssueInputParameters()) if (transitionValidationResult.valid) { def transitionResult = issueService.transition(loggedInUser, transitionValidationResult) if (transitionResult.valid) { log.warn "Transitioned issue ${outerIssue} through action ${transitionId}" } else { log.warn 'Transition result is not valid' } } else { log.warn 'The transitionValidation is not valid' } }
Discovered an issue? Report it here

Suggested for you