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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,560,461
Community Members
 
Community Events
185
Community Groups

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

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

0 votes
Daniel Ebers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 07, 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

@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

@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 ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events