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

How to Modify the Story when Child Changed

Okay, I got some code here and I printed my stuff along the way. I basically followed the instructions listed here:

This worked, at least it did in 2017.

In my case, I needed to change the parent, so this is my version of the code:

import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl

def log = Logger.getLogger("com.acme.CreateSubtask")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def parent = issueManager.getIssueObject(event.issue.getParentObject().getKey()) 
def actionId = event.issue.getStatusId().toInteger()
def transitionValidationResult
def transitionResult
def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueService issueService = ComponentAccessor.getIssueService()

log.debug("The actionId is: " + actionId)
log.debug("The parent issue type is: " + parent.getIssueType().name)
log.debug("Issue key is: " + event.issue.getKey())
log.debug("Name of parent is: " + parent.getKey())

if (parent.getIssueType().name == "Task") {
transitionValidationResult = issueService.validateTransition(currentUser,, actionId,new IssueInputParametersImpl())
log.debug("Current user: " + currentUser.getName())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid()) {
log.debug("Transitioned issue $parent through action $actionId")
} else { log.debug("Transition result is not valid") }
} else { log.debug("The transitionValidation is not valid") }

I'm logging a bunch of stuff and everything checks out with the exception of the last else-statement. Here is my log:


I passed the script into a custom script listener and everything is checking out there too. I got it listening to my workflow.

ISR-14 is the child: CORRECT

ISR-13 is the parent: CORRECT

The action id looks really big and that is probably causing the validate transition to fail.

If this looks too complicated, all I really want to do is change the parent status to "Selected for Development" when Child is changed to that status. 

Don't worry, I understand that I need to account so that when the child is changed to Done, that the parent doesn't do that too if more subtasks exist.


1 answer

0 votes
Antoine Berry Community Leader Mar 28, 2019


here is a snippet that can help you transition your parent issue (of course update the transition id). Keep in mind that the current user needs to have permission to transition the parent. 

import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.util.JiraUtils

String userKey = currentUser.getKey()
def parentIssue = issue.getParentObject()
int transitionId = 11

WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );


Suggest an answer

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

Localize Smarter with the Transifex Integration for Bitbucket

Over 52% of internet users say obtaining information in their own language is more important than price and 75% of the world’s population doesn’t speak English. It’s no wonder then that successful gl...

221 views 0 3
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