How to get Parent issuekey from its subtasks in jira cloud

chinmay konkar April 30, 2021

i am using jira software cloud instance and also having scriptrunner installed. i want to get parent issue key from its subtask on one of the transition using scriptrunner.

or can i copy one custom field value from subtask to its parent issue type field?

2 answers

1 vote
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.
May 3, 2021

Hi @chinmay konkar 

We have an example here where it shows how to sum up values from fields on a subtask and store them in the parent. You can use this example as a guide/reference to help create the script that you require.

I hope this helps.

Thank you

Kind Regards

Kate

chinmay konkar May 3, 2021

Thanks a lottt ! @Kate Kabir 
It worked for me.

Like Kate Kabir likes this
0 votes
Juan Manuel Ibarra
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.
April 30, 2021

Hello in a transition you can get the key (or any other field from the parent of a subtask)

 

public String getParentKey(issue){

def parent = issue['parent'] as Map
parent.key

}

Such a function returns the parent key

If what you need is to copy info from the subtask to the parent you have to obtain the values of the fields, build a map and perform an update of the parent

public static void updateIssue(issueKey, updateMap){

def result = put("/rest/api/2/issue/${issueKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header("Content-Type", "application/json")
.body([fields:updateMap])
.asString()

if(result.status != 204)
throw new Exception(result.body)
}

Regards 

chinmay konkar May 3, 2021

@Juan Manuel Ibarra  thank you so much for your reply !

Suggest an answer

Log in or Sign up to answer