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

Scriptrunner (Jira Cloud) Transition An Issue When Linked Issues, are Resolved.

Hello Community,

I would like to create a post-function script to transition an issue [issue-x] from status-y to status-z when all linked issues to [issue-x] via a [custom] link type, are resolved. Running Jira Cloud.

Not sure the type of link matters, figure I'd mention it.

There are dozens of posts along this topic, both here and on Adaptavist related blogs, however either they are outdated or seem to be geared towards hosted Jira. I've used the script console to poke around and attempt to pull bits and pieces from various posts, alas have failed. Being new to groovy and in the interest of learning, I would very much appreciate if someone could help me to generate this first script. I have access to the customfield ids and any other info required to plug in. 

Have a feeling this could help a lot of people who are in my position.

Thanks ahead.

2 answers

1 accepted

0 votes
Answer accepted

Hi Adam,

Thank you for your question.

I have created an example script located here which you can run on the script console inside of Jira Cloud in order to get all of the linked issues for an issue and to transition if the issue if all the issues are in a specified closed status.

You will be able to use this script as a reference to see how you can get all linked issues and to transition the issue when they are all closed so that you can create the script which you require.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



Hi Kristian,


Happy new year and thanks for getting back to me. Before the holidays I spent time with the sample query you shared. The script console gave me errors, notably at line 24 (minus the legal text). Due to that legal text I'm not sure what I am allowed to mention publicly, however, it looks like there are a few ways to handle iterating on the FindAll function which is where this gets caught up. 

I am available to chat offline to work out the nuances and return to the thread here with a resolution if that is preferred. 


Thanks again,



Hi Adam,

Thank you for your response.

Can I please ask you to confirm if in the sample script shared if you updated lines 10, 13 and 17 to include the Issue Key, Status ID and transition ID by removing the text that contains the  < > angle brackets and by replacing it with just the value inside of the quotation marks.

If you are still encountering issues can you please post a screenshot of the error that you are receiving so that we can advise on this thread how to resolve the issue. 



Hey Kristian - nearly a year later and I've finally made my way back. I've accepted the answer. Thank you for the most part I didn't need to make any edits, yet I'm going to call out several things that folks should be aware of, when considering this action

  1. Line 13:

    // Specify the name of the version to extract from the issue
    def closedStatus = '<ClosedStatusHere>'

    There could be x number of tickets linked who follow various workflows utilizing different done statuses. Thus the Closed status I don't think works. I think we're looking for the "ClosedStatusCategory" [of the linked tickets]; "Done".

    1. Which would change line 31
    2. And line 36
  2. Tripped myself up on line 46 - I didn't initially declare the transitionID as a variable. My suggestion for the documentation is making it clear there is a variable:
    .body([transition: [id: "${transitionID}"]])

Lastly, used as a listener this is going to be an extremely expensive call. Unless I'm missing something, Issue Updated is the only event for us Cloud folks that we can use, and that event runs on everything. Folks should be advised to have conditions which will narrow the scope to prevent running this script on every issue updated event for a given project(s).

Hi @Kristian Walker _Adaptavist_ , / @Adam Dulberg ,

I am on cloud JIRA

I am trying to achieve the same what you discussed above, I have used your code but i am getting error. please have a look my attached screen short .


def issueKey = "<ETM-495>"

// Specify the name of the version to extract from the issue
def closedStatus = '<Cancelled>'

// Specify the transition to execute on the issue
// NOTE - The transition ID must represent a valid transition for the workflow that the issue uses.
def transitionID = '<11>'

// Specify a boolean to flag if all issue links are resolved
boolean allIssueLinksResolved;

// Get the issue object
def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')

// Find the linked issues
def linkedIssues = result.body.fields.issuelinks

// if all issue links have the Done status set the flag to true
allIssueLinksResolved = true

// If any of the linked issues do not have the done status set the flag to false
if (linkedIssues.findAll{!closedStatus.contains(}){
allIssueLinksResolved = false

// If all issue links are resolved transition the issue
if(allIssueLinksResolved == true){

// The rest call to transition the issue
def transitionIssue = post("/rest/api/2/issue/${issueKey}/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: transitionID]])

return "All issue links are to closed issues and the issue has been transitioned."
// If the issue contains unresolved linked issues return a message and do not transition the issue
}else if (allIssueLinksResolved == false){
return "The issue contain issue links which are not closed"


script error.PNG

Hi @Musku Nagaraju,

have a look at the error message again. It quite clearly expresses what the problem is: a missing curly brace '{'.

If you copied your whole script into here, you should add a curly brace at the end of your script.


Hi @Matthias Gaiser _K15t_ ,

I have put curly brace, their is no error now but the workflow sync not working.


I have used this code in post function "run script"


scripr logs.PNG

Hi @Musku Nagaraju,

please have a closer look at the error message again - it tells you more information about the problem: Illegal character in path at index 89.

If you want to use a solution like Scriptrunner, I highly suggest to read error message, try to understand them and see if you can solve the problem.

If you don't feel equipped well enough for that, you can always look for other apps where you don't need to code or look for an Atlassian solution partner which will help you in the configuration.


Hi Musku,

Thank you for your comment.

I have reviewed your script above and notice that in the issueKey,transitionID, and closedStatus variables that you are have defined your values inside of < and > tags and these tags should be removed as you just need to define your values as plain text inside of the speech marks for the variables. 

In the example script, the < > tags are just to show where you need to update the script and to specify values as a string and should be removed.

Also please note when reusing the sample script you must keep the block comment from the top of the script as the licensing comment which is required to reuse the script sample provided.



Suggest an answer

Log in or Sign up to answer

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