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 change parent's status Automatically?

Hi Everyone,

In our project, there is a scenario where we have sub-tasks if we changed the status of sub-task into "Blocked" all the parent's issue status should be changed to Blocked.

Parent's can be more than 2 levels.

For Ex: Feature(parent)--->Epic(parent)-->Story(parent)--> story has 2 sub-tasks(Assume A & B), if I change the status of A or B to "Blocked" all the parents(All the way to feature) status must be changed to "Blocked".

To achieve this I've written a script which is just updating only parent status not all the layers. If you see above hierarchy if I change the status of Sub-task(A) it only updating the status of Story but not Epic and Feature.

 import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueImpl
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Category

Category log = log
log.setLevel(org.apache.log4j.Level.DEBUG);

if( issue.getIssueType().getName().equals("Sub-task"))
{
log.info(issue.getIssueType().getName())
log.info(issue.getStatus().getStatusCategory().getName())

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

Issue parentIssue = issue.getParentObject()
log.info(parentIssue.getIssueType())
log.info(parentIssue.getIssueType().getName())
log.info(parentIssue.key)

log.info("Updating the parent issue to Blocked")
((IssueImpl) parentIssue).setStatusId("10306");
((IssueImpl) parentIssue).store();

Issue ppIsue = parentIssue.getParentObject()
log.info(ppIsue.getIssueType())
log.info(ppIsue.getIssueType().getName())
log.info(ppIsue.key)

log.info("Updating the Pparent issue to Blocked")
((IssueImpl) ppIsue).setStatusId("10306");
((IssueImpl) ppIsue).store();

}

 

Any help would be appreciated!

Thanks in advance,

Manikanta

2 answers

0 votes

Hi Manikanta,

This is due to issue hierarchy. A story is plain issue, which can have sub-issues, so you can get parent story for sub-task. Epic is also just plain issue and a story is connected with epic using Epic Link field. So you can get epic by Epic Link Custom Field. 

Hi Manikanta:

I am getting into this topic due I want to help my team to the parent ticket be updated automatically if the child is updated. Could you let me know where did you add the script above mentioned? 

What I want to do basically is when the first subtask is moved from To Do to In Progress the parent ticket (story) be updated as well to in progress. 

It'd be the main one... now if also can update the story as how the subtask is moving along the board would be terrific but let's to step by step :)

 

Thanks in advance!

 

Sincerely,

 

Lucio Lara

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

275 views 1 2
Join discussion

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