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

Hi All, I am looking for a script where i want to change the status of Issue on the basis of linked

shrikant maheshwari May 7, 2021

Hi All,

I have 2 projects one is Dev and the other is Release project .

I am looking for a script where -

I want to change the status of a Issue in Release project once all the linked issues which are DEV issues are closed.

I have tried different sample scripts but it does not seems to be working . Also please let me know do we have to write a script listener for this.

 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Daniel Ebers
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.
May 15, 2021

Hi @shrikant maheshwari

from reading your requirement using feature fast-track transition from Script Runner could be an alternative.

I found a similar discussion which might be helpful:

Regards,
Daniel

0 votes
Ravi Sagar _Sparxsys_
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.
May 7, 2021

Hi @shrikant maheshwari 

Share your script, let us try to fix it.

Few things to note.

  • You have to fetch the linked issues based on the type and most importantly the direction. Inward or Outward links.
  • When you transition the issue, make sure there is a relevant transition in those issues.

There are plenty of script on our script library: https://library.adaptavist.com/

Ravi

shrikant maheshwari May 10, 2021

@Ravi Sagar _Sparxsys_  Hi Ravi,

please find the below script -

The below script is not updating the status of the destination issue.

  • Suppose I Have Issue A and Issue B , Issue A is in Source Project and Issue B in Destination Project
  • and Issue B, "Is Blocked By" Issue A then as soon as the Issue A is closed the Issue B should also be closed. 
  • I have placed the below script in the post function of Closed status of Issue B

But still the status of Issue B is not getting Updated as soon as the Issue A gets closed.

import com.atlassian.jira.issue.link.LinkCollectionImpl;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParametersImpl

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 31
def transitionValidationResult
def transitionResult

List allOutIssueLink = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
for (Iterator OutIterator = allOutIssueLink.iterator(); OutIterator.hasNext();) {
IssueLink issueLink = (IssueLink) OutIterator.next();

def linkedIssue = issueLink.getDestinationObject().id
transitionValidationResult = issueService.validateTransition(currentUser, linkedIssue, actionId,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.debug("Transitioned issue $issue through action $actionId") }
else
{ log.debug("Transition result is not valid") }
}
}

Ravi Sagar _Sparxsys_
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.
May 10, 2021

Hi @shrikant maheshwari 

Is the action id 31 valid for the target issue? Use Script Console to first check if the direction of the link is correct. The code above will get your outward links. Also how are you triggering the issues to be transitioned in your target project? Using a post function. The code above is not checking whether all the issues of a specific type (common release for example) in your source project are closed or not.

Break down your script to

- To get correct issue link direction

- Check if other issue in the release are closed or not

- Check for the relevant action id in your target issue's workflow

I hope it helps.

Ravi

shrikant maheshwari May 10, 2021

@Ravi Sagar _Sparxsys_ 

Hi Ravi,

The transaction id 31 is valid for the Target Issue. And i have placed this script in the post function of the Target Issue. Also there are no other issues linked to Target Issue.

SO the scenario is 

Source Project - A , ISSUE A

Destination Project -B, Issue B

Now Issue B is "Is blocked by" Issue A i.e Issue A "Blocks" issue B and as soon we close Issue A the Issue B should also be closed.

Could you please help in changing the script ?

TAGS
AUG Leaders

Atlassian Community Events