How to change parent's status Automatically?

Bunty November 14, 2018

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
Lucio Lara Cruz October 21, 2019

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

0 votes
Aleksandr Zuevich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 14, 2018

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. 

Suggest an answer

Log in or Sign up to answer