Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,393
Community Members
 
Community Events
168
Community Groups

Update ticket status when all linked tickets are Done

Hi there. hope all in great health.

I have been searching, but most results returned sub-task related answers.

I am trying to achieve as follows:

1. I have a ticket in Project A.

2. In project A, there are tickets from project B and C, which is linked as created, meaning, in  Project A, under the Issue Links section, these 2 projects are under created.

3. While in the ticket each in project B and C, the issue links would be created by the ticket in project A.

4. How could i update the status of the ticket in project A also to done/completed when tickets in project B and C are done/completed?

5. We have jira script runner, i am thinking using Listener.

Any pointers is greatly appreciated! Thank you!

1 answer

1 accepted

1 vote
Answer accepted

Hi @Kamal Iqlaas Ismail

For your requirement, you should use a Post-Function.

Below is a sample code for your reference:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl

def issueService = ComponentAccessor.issueService
def issueLinkManager = ComponentAccessor.issueLinkManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def outwardLinks = issueLinkManager.getOutwardLinks(issue.id)
def actionId = 31

outwardLinks.each {
def destinationObject = it.destinationObject

if (destinationObject.projectObject.key in ['MOCK','TEST']) {

def transitionValidationResult = issueService.validateTransition(loggedInUser, destinationObject.id, actionId, new IssueInputParametersImpl())

if (transitionValidationResult.isValid()) {

def transitionResult = issueService.transition(loggedInUser, transitionValidationResult)

if (transitionResult.isValid()) {
log.warn "Transitioned issue $issue through action ${actionId}"
} else {
log.warn 'Transition result is not valid'
}
}
else {
log.warn 'The transitionValidation is not valid'
}
}
}

Please note that the sample code provided above is not 100% exact to your environment. Hence you will need to make the required modifications.

Below are the screenshots to configure the Post-Function:-

1. Go to the workflow of the project from which you want to trigger the change. In this example, the project that will trigger the transition is the Sample project. Once you are in the workflow, add a Post-Function as shown in the image below:-

post_function_config_1.png

2. Next, select the Custom script post-function [ScriptRunner] option as shown below:-

post_function_config_2.png

3. Once you are in the Custom script post-function [ScriptRunner] screen, add the code after you have modified it. Next, save the code and Publish the change made to the workflow.

post_function_config_3.png

Below are a few test screenshots for your reference:-

1. In this test case, 3 projects are used, i.e. Sample, Mock and Test. The issue in the Sample project blocks issues from both the Mock and Test projects, as shown in the image below.

Note: In your case, although you are using the created and created by issue links, it will work the same.

image1.png

2. Similarly, the Issues from the Mock and Test project are blocked by the issue from the Sample project as shown in the images below.

image2.pngimage3.png

3. Next, the issue from the Sample project is going to be transitioned to Done, and as expected, the linked issues from the Mock and Test projects are transitioned to Done as shown in the images below:-

image4.png

 

image5.png

image6.png

I hope this helps answer your question. :)

Thank you and Kind regards,

Ram

Hi @Kamal Iqlaas Ismail

Kindly accept the answer if it solves your question.

Thank you and Kind regards,

Ram

Like Mike Prill likes this

Suggest an answer

Log in or Sign up to answer