inherit custom field values from parent to subtasks


I created a custom field in Jira which is "Customer ID" and I would like if a parent task has this field, all subtask inherit the value of this custom field automatically and no one allowed to change custom field value of it in subtasks.

Could you please kindly tell me how can I do it ?

Best Regards,

4 answers

0 votes
Mahesh S Community Champion Sep 28, 2016

Introduce a 'scripted field' using script runner plugin. Hide it from the screens. Using the scripted field, update the custom field value in the subtasks.


Introduce a 'scripted field' using script runner plugin. Set it for the subtasks alone using field conf or screen or set field context. Get the custom field value form parent and just display in the subtasks. 



Hi Amir,

as Mahesh mention you can use Script runner addon.

  1. add 'Custom script post-function' to your workflow on Create transition
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.*;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
def IssueManager issueManager = ComponentAccessor.getIssueManager();
def CustomFieldManager customManager = ComponentAccessor.getCustomFieldManager();
def IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
//get and update value of my customField CRM ID
try {
    if (issue.getIssueType().isSubTask()) {
        def String crmID = issue.getParentObject().getCustomFieldValue(customManager.getCustomFieldObjectByName('CRM ID'));
  		customManager.getCustomFieldObjectByName('CRM ID').updateValue(null, issue, new ModifiedValue(null, crmID as Double), changeHolder);
} catch (Exception ex) {

2. move your post function till the end of list, at least after Issue Created.

3. publish your update workflow

Happy inheriting smile



Mahesh S Community Champion Sep 28, 2016

Hi Peter, my suggested solution is with scripted field and yours is with scripted post function. Glad to see your script here. However, once we add this scripted post function, subtask's custom field will get updated from the parent  when it make a transition.

But, how will the existing issues in different states will behave in this manner, when we do not make any state changes?

Existing issue will not be affected. You have to do one-time-update with another script...

Mahesh S Community Champion Sep 28, 2016

Exactly! But, I believe Amir needs it for all issues both newly creating ones and existing ones.

You can create a further custom field "Customer ID Sub" which should be configured only on the view screen of you sub task. (In the view screen it can be configured as read only).
Use the plugin Workflow Essentials and put the post function "Copy field value from parent to sub-task " into the create transition of you sub task. As soon the sub task is created the post function will copy the field from "Customer ID" to "Customer ID Sub". 

Mahesh S Community Champion Sep 28, 2016

True it works using the post function when we create or do a transition. But how will it update when you make changes in the parent dynamically and no state changes happen in subtasks?

The Field Teller plugin allows you to configure fields to be displayed in the subtask. No value copying is done and values cannot be changed from the subtask. It's not a free plugin, but it is not really expensive either.

Hope it helps.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,750 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you