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 - transition all parent issues when child issue transitions

I'm using Scriptrunner for Jira Cloud. I've found the post function to transition a parent when a subtask transitions, but I would like the entire hierarchy to transition as well - Sub-task, Story and Epic. I'm not finding how to get the parent of any issue type except Sub-task. 

def transitionID = '21' // My global In Progress transition ID
def parentKey = 0
if (((Map) issue.fields.issuetype)?.name == 'Sub-task') {
parentKey = issue.fields.parent.key
} else {
What goes here?
// The rest call to transition the issue
def result = post("/rest/api/2/issue/${parentKey}/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: transitionID]])

// Check if the issue was transitioned correctly
// Log out the issues updated or which failed to update
if (result.status == 204) {"The ${parentKey} issue was also transitioned by the post function.")
} else {
logger.warn("The post function failed to transition the ${parentKey}issue. ${result.status}: ${result.body}")

Obviously a WIP but help with this part would be appreciated 

1 answer

1 accepted

0 votes
Answer accepted

A task, story name it what you want don't have a parent, they can have epic link to relate them with the epic they belong to.

Jira works with only three levels of issues:

tasks (give the issuetype the name you want)
subtasks (give the issuetype the name you want)
so the level you don't have is the task to epic level jump

obvously, you can create "fake" levels via links from issue to issue or something like that, but that's just a workaround

this is the JSON that rest/api/latest/issuetype returns for one issuetype:

   "name":"Subtarea Petición HR",

Only issuetypes with "subtask":true have parent issue

So maybe you should filter issues for that "subtask":true instead of the name of the subtask itself

The hierarchy we have includes:

Story or Task

If one looks at a Story issue, there is a field "Epic Link". Is this field not exposed from within the JSON? 

'epic link' is treated like a customfield, in my jira is 'customfield_10001'

you can get the value of that field with

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject(xxxxx) //being xxxxx the id of the field

// or
// def cField = customFieldManager.getCustomFieldObjectByName('custon field name')

def cfValue = cField.getValue(issue)

// def cfValue = issue.getCustomFieldValue(cField)


if you call 


you get a JSON with all the fields for that issue. , you also have issuetype with the info i gave you in the previous post, the status, and all the info about fields in the issue

"description":"xxxxxx xxxxxx",


.... lots of other customfields...



.... lots of other customfields...

"description":"Un problema que dificulta o impide el funcionamiento del producto.",

.... lots of other customfields...

"description":"The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.",

.... lots of other customfields...

"name":"TO - Message Broker",

.... lots of other customfields...



Thank you, Fran, this was my missing piece. I have my script working now.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

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