Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

[ScriptRunner] [Server/Data-Center] Copy Fields to Subtask


I am trying to set Fix Version and Custom Field "Team Codes" when a sub-task is created.  I have an Issue of Type PTR and I go to More -> Create sub-task.   The PTR has Team Codes and Fix Version fields defined.   As a test, I am using the the example script from Script Runner with the single change of modifying List copyCustomFields = ["Team Codes"].  I threw some log.error("blah") to see where it was existing and it's inside this if-statement:


if (!parentIssueId || underlyingIssue) {
    // this is not a subtask, or issue already exists, so don't set default values
Because it's exiting early, it doesn't perform any of the copy of the fields.  I have the script-runner as a post-function in the create transition.  I also tried moving the function from the top of the post-functions to the bottom that didn't change anything (I didn't expect it to...).
Any ideas?

2 answers

1 accepted

0 votes
Answer accepted

I found this post:

Which lead me to this post:

This worked for me.  I needed to copy a custom field as well as system field, Fix Version/s.  


NOTE: ScriptRunner has a predefined Post-Function script called "Copy field values [ScriptRunner]" -- I couldn't get this to work properly; the log says that it runs without error but after the subtask creation, the field is empty/null, which is why I had to go the custom script route.

NOTE 2: There is also a free plugin that only copies custom fields not system fields, called Copy to Subtask Plugin. I also could not get this plug in to work for Custom Fields.  Creates a menu item Create Subtask - JCTS.

NOTE 3: Finally, JMWE (Copy field value from parent issue (JMWE plug-in)).  Also could not get it work for custom or system Fields.

Hi @Dan Long,

I think the best way to do this is by a postfunction on create in sub-task workflow.

I guess I'm not sure what you mean? Can you give me more detailed steps? I made a copy current workflow then assigned that to the sub-task, but the post-functions are the same.

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