JIRA Cloud ScriptRunner get Parent Field value to Update Subtask

Dan
Contributor
February 12, 2020

In JIRA cloud using ScriptRunner I'm trying to get the parent summary so I can do a little string manipulation to add my own prefix to the sub-task summery generated via a ScriptRunner postfunction.

Anyone know how to get the parent field values and update the subtask using Scriptrunner?

 

I gather at the sub task creation "issue" realy means the parent? So I figured I could just trace the property value like this in the Additional code block.

 

import org.apache.log4j.Logger

logger.info("Parent task summary? " + issue.fields.summary); //doesn't work


logger.info("Subtask summary? " + subtask.fields.summary); //doesn't work either

Just trying to log it kills the function to generate the sub.

 

 

 

3 answers

1 accepted

0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2020

Hi Dan,

Thank you for your question.

I can confirm that your code shown above will not work as you cannot define the log4j import statement as this is not valid in *ScriptRunner for Jira Cloud* as the logging comes bundled so you can just write your logging statements without defining the log4j import statement.

I can also confirm that you are correct that in the *Create Subtask post function* provided by ScriptRuner for Jira Cloud that the issue object contains all of the fields from the parent issue which triggered the post function and that the subtask object contains all the fields which are being set on the subtask that is being created.

Finally, I can confirm that in the code snippet located here that the second example shows how to set the subtasks summary to be the summary from the parent issue with some extra appended and this may be a useful reference to help you to achieve your requirement.

I hope this information helps.

Regards,

Kristian

0 votes
Dan
Contributor
February 17, 2020

Thanks Kristian, this one line was exactly what I needed.

subtask.fields.summary = issue.fields.summary + 'hello dolly'
0 votes
Janene Pappas
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.
February 12, 2020

Suggest an answer

Log in or Sign up to answer