How to get epic issue key and story issue key from its task issue

chinmay konkar June 14, 2021

Hello Everyone ,

 

I am using jira software cloud. and I want epic key from its story and task issue. How can I get this key using scriptrunner for jira cloud

OR

I want to update the epic custom field value on transition update of the its task issue

How can I do this ?

Regards,

Chinmay

2 answers

1 vote
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2021

Hello @chinmay konkar 

Welcome to the community.

You can use the Automation feature of Jira Cloud to create a rule that is triggered by the transition update of the task. You can add to the rule a Branch to affect the Related Issues = Parent Epic, and then you can add an Action to the rule to make the change you want in the Epic.

Here is the home page for the documentation on the Automation feature:

https://support.atlassian.com/jira-software-cloud/docs/automate-your-jira-cloud-processes-and-workflows/

0 votes
Kate Kabir
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.
June 14, 2021

Hi @chinmay konkar 

I hope you are doing good.

As per your enquiry, we have an example of how to set field values in the script and then to run the Get Issue Fields example script on the Script Console as this will return the JSON structure for the issue and show how the data is stored for the field. Then, you can get the epic issue using the Epic Link Field.

Example: 

def issueKey = 'TP-1'

def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
return result.body.fields
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}

Also, you can use the EPIC Link to get the key to the epic. We have an example to show you how to obtain the epic name and key here. You can use this as a guide and modify it to achieve your requirements.

Hope this will help.

Thank you.

Kind Regards

Kate

chinmay konkar June 15, 2021

Hi @Kate Kabir 

Thanks for the reply. I am able to get the epic key from its linked story.

But I am not able to get the story key from its (story's) task. How can I get this story key? OR I am not able to get the epic key from task. How can I get this story key?

Basically the hierarchy is :

sub-task is linked to task, task(with its sub-task) is linked to story, and story(with its tasks and subtask) is linked to epic

Suggest an answer

Log in or Sign up to answer