Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Want to copy fields from parent to subtask

Hi All,


I have the fields in the parent want to display the values in th subtask.


Eg: I have associate name field (insight custom field) =abc & hiring manager (insight custom field) = xyz wanted the display the values of that in the subtask as requested for (custom field) = abc & associate name of parent values and opened by = xyz as hiring manager values in the subtask view page.


Please help me in the script runner code.


I tried to write the code in the script runner ,but iam getting null values or abc (CMDB -7899).

1 answer

0 votes
Ravi Sagar Community Leader Jan 03, 2021

Hi @kiranmai genkolla 

Are you on Cloud or Server?

How do you want to copy the fields from parent to sub task? When  the parent is transitioned or updated  or when sub task is created?

Use this script to get started and modify further as per your needs.

Share your script, let us try to make it work.


hi ravi,

i want to write the cript in the create transition of subtask .

as of now checking this in script console .


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.fields.FieldManager

def issue = ComponentAccessor.getIssueManager().getIssueObject("IT-14555")

def parentIssue = issue.parentObject

def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13263")//Parent insight custom field (Assciate name)
def customField1 = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13153")//Parent insight custom field (Hiring manager)
def requestorforCF = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13416")//requested for (custom field in subtask (single line text field))
def openedby = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13257")//Opened by (custom field in subtask (single line text field))
def linkedIssueCustomFieldValue = parentIssue.getCustomFieldValue(customField)
def linkedIssueCustomFieldValue1 = parentIssue.getCustomFieldValue(customField1)
issue.setCustomFieldValue(requestorforCF, linkedIssueCustomFieldValue)
issue.setCustomFieldValue(openedby, linkedIssueCustomFieldValue1)

log.warn("request for :" + requestorforCF)
log.warn("opened by :" + openedby)

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