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

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 check in listener that sub-task's parent was changed? Edited

I have a task: copy components from parent to sub-task when sub-task's parent changed.


I have Parent 1 with component ABC and its sub-task 1 with the same component ABC and Parent 2 with component DEF. I move sub-task 1 to Parent 2, so sub-task 1's component should change to DEF.


In listeners I usually use event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == 'fieldName' } so I wonder if there is a field in sub-tasks that contains parent issue value so I can check if this field changed.

If no, is there another way to implement it?

1 answer

1 accepted

0 votes
Answer accepted

Found the field name myself :) it is "Parent Issue"

Maybe it will help someone, the code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
// current issue
def issue = event.issue as MutableIssue
if (issue.getIssueType().getName() == "Sub-task") {
// the name of the field to check
final String fieldName = "Parent Issue"
// user that will make updates
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// check if a right field was updated
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find
{it.field == fieldName}
if (change) {
def issueManager = ComponentAccessor.getIssueManager()
// get components of parent issue
def components = issue.getParentObject().getComponents()
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
} else return
} else return

Suggest an answer

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

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

216 views 2 5
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