post function to set subtask fields from parent on create

Ron Eberle March 20, 2015

I'm trying to do something that is well documented but for some reason it's not working for me....

I would like to default some custom fields when creating a subtask from the parent (from the JIRA UI) to values from the parent.

I have created the following post functions on the create issue transition. But the fields are not pre-populated with defaults from the parent when the 'create subtask' page is displayed.

  1. The value(s) of field Platform(s) will be set from the issue's parent (replacing existing values).
  2. The value(s) of field Application will be set from the issue's parent (replacing existing values).
  3. Creates the issue originally.
  4. Fire a Issue Created event that can be processed by the listeners.

What am I missing?

3 answers

1 accepted

0 votes
Answer accepted
Ron Eberle March 21, 2015

I thought that was the case but after reading this https://confluence.atlassian.com/display/JIRAKB/Post-Function+in+the+Create+Issue+Transition+does+not+Update+Assignee+due+to+Order?utm_source=SAC&utm_medium=dashboard it made me think that somehow it was executed before the create screen was displayed.

Is there any way to default a custom field on the subtask from the parent when the create screen is initially displayed? In fact, I really don't even want to show the custom field on the subtask but if I hide it I run into the problem in that the subtask rows are not returned in the JQL results.

Any help would be appreciated

Udo Brand
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.
March 23, 2015

Sorry for the late reply. I didn't recieve a mail about your answer. What you can do is to remove the fields from the subtask create screen. Use your postfunction as before. So once a subtask is created the fields are inherited from the parent. Don't hide the fields, simply don't put them on the view, create or edit screen of your subtask. You will be able to query them. Hope that helps.

Ron Eberle March 24, 2015

That did the trick. Thanks very much! Note that I also opened this issue but I think that your solution may help others who want to set the field value on the subtask as opposed to providing a visible default. https://support.atlassian.com/servicedesk/customer/portal/23/JST-133222 thanks again Ron

1 vote
Udo Brand
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.
March 20, 2015

Well, the postfunctions will run only when you hit the create button on the create screen of your subtask. That's why the fields are not populated on the create screen.

0 votes
andreas
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.
November 21, 2016

There's now a very easy to configure way to keep fields for parents and sub-tasks in sync using Automation for JIRA!

You can easily modify related issues (such as parents, stories, sub-tasks, epics, linked issues and even JQL) using our related issues action and condition:

(this example updates the description, but pretty much any field can be edited including custom fields)

For more details see https://blog.codebarrel.io/synchronize-parent-and-sub-task-issues-with-automation-for-jira-bdcca6c9d453

Suggest an answer

Log in or Sign up to answer