Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Transition parent when all sub-tasks are resolved for Initiative Epic Relationship Edited

Hi all! Trying to write a script in Adaptavist ScriptRunner to update the Initiative (advanced roadmaps fields) when all epics under it are "Closed". I created a scripted field for the Initiative-Epic Relationship called "Initiative-Epic Link". I borrowed some of the code from this article and tinkered around with it for quite a while but cannot seem to get it working. Has anyone successfully got this working or is any experienced in this type of thing? I'm still a novice at writing scripts. Thanks in advanced! 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions

def issueManager = ComponentAccessor.issueManager

def issue = issueManager.getIssueObject("DEMO-130") //issue key

log.warn "issue: "+issue

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def epicInitLink = customFieldManager.getCustomFieldObjectByName("Initiative-Epic Link")

def cfFieldValue = issue.getCustomFieldValue(epicInitLink)

def parentIssue = issueManager.getIssueObject(cfFieldValue.toString()) //get parent issue object

// To shows cfFieldValue has value
log.warn "Initiative-Epic Link value: "+cfFieldValue

// the name of the action you want to move the issue to
final String actionName = "Closed"

// the name of the issue link
final String issueLinkName = "Initiative-Epic Link"

def workflow = ComponentAccessor.workflowManager.getWorkflow(issue)
def actionId = workflow.allActions.findByName(actionName)?.id
def issueLinkManager = ComponentAccessor.issueLinkManager

// Find all the linked - with the "Initiative-Epic Link" link - issues that their status is not completed
def linkedIssues = issueLinkManager
.findAll { == issueLinkName }
*.destinationObject?.findAll { != "Complete" }

// If there are still open linked issues (except the one in transition) - then do nothing
if (linkedIssues - issue) {
log.warn "Not all Epics are Closed"

def issueService = ComponentAccessor.issueService
def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.setComment("This Initiative closed automatically because all the Epics in this Initiative are closed.")

def transitionOptions = new TransitionOptions.Builder()

def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def transitionValidationResult = issueService.validateTransition(loggedInUser,, actionId, issueInputParameters, transitionOptions)
assert transitionValidationResult.isValid() : transitionValidationResult.errorCollection

def result = issueService.transition(loggedInUser, transitionValidationResult)
assert result.isValid() : result.errorCollection

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

424 views 5 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you