Copy summary from linked issue(parent issue) to custom field of child issue when child Issue created
Asked by Venkatesh Pettem:

Hello Team,

I am trying to copy "summary" from linked issue(parent issue) to custom field of child issue when child Issue created through Big Picture.

here is my Listener at created event.

import com.atlassian.jira.component.ComponentAccessor  

def issueManager = ComponentAccessor.issueManager  
def customFieldManager = ComponentAccessor.customFieldManager  
def issueLinkManager = ComponentAccessor.issueLinkManager

def issue = event.issue

def currentIssue = issueManager.getIssueObject(issue) // Replace with your issue key  
def customField = customFieldManager.getCustomFieldObjectsByName("Related Project Task") // Replace with your custom field name

def linkedIssues = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId()).collect { it.sourceObject }  
def systemFieldName = "summary"  
def field = fieldManager.getField(systemFieldName)

linkedIssues.each { linkedIssue -\>  
def fieldValue = linkedIssue.getFieldValue(field)  
if (fieldValue) {  
currentIssue.setCustomFieldValue(customField, fieldValue)  
issueManager.updateIssue(ComponentAccessor.jiraAuthenticationContext.getloggedInUser, currentIssue, EventDispatchOption.DO_NOT_DISPATCH, false)  
}  
}  
Thanks,  
Venkatesh


Answers:
author: John Price
body: You're getting there! Your rule is firing when an issue is \*linked\* to a parent, which is a bit different than what you said before (when a child is created). Here's a working rule for copying a custom field to a newly created child - you can edit it or have multiple rules if you want to handle both "I created a new child" AND "I linked an existing issue to a new parent".  

Here's my rule:  

![jira copy field from parent.png](https://community.atlassian.com/t5/image/serverpage/image-id/342729i3F7B85AF19710B1E/image-size/large?v=v2&px=999 "jira copy field from parent.png")

Note that there is a "Multiple Issue Events" trigger that could handle both Create/Link events, but I think those are harder to read.

comments: author: Venkatesh Pettem
body: your mentioned rule will copy Request type (custom field) value of Parent Issue to Request type of newly created Issue.

How do I **copy** (map) **summary of existing issue** to the newly created issue **(** which is then **linked** as "Child Of" existing Issue**) custom field (single text) value?**

Please Advise.

Thanks,

Venkatesh


author: John Price
body: Hi [@Venkatesh Pettem](/t5/user/viewprofilepage/user-id/5541453) - I suggest spending some time playing with the rules and the documentation and templates at <https://www.atlassian.com/software/jira/features/automation> . In the meantime can you mark my answer correct? Your last question is really just about details - copying different fields or editing the logic to include a linking event is very similar to the example I gave. You can do pretty much anything with automation!


author: John Price
body: Hey [@Venkatesh Pettem](/t5/user/viewprofilepage/user-id/5541453) -

Looks like you are doing this by scripting. Data Center now comes with Automation for Jira, which makes this sort of thing a snap and is more maintainable and easier to troubleshoot. Have you played around with that?  

See for example: <https://support.atlassian.com/automation/kb/jira-automation-how-to-copy-parent-issue-fields-into-sub-tasks/>

There's a "Copy Field From Parent" action and you can use conditions to only execute for certain issue types.

comments: author: Venkatesh Pettem
body: Hi [@John Price](/t5/user/viewprofilepage/user-id/183241),

I have tried with the bellow automation rule to copy parent summary value to child(linked issues) custom field "Related Project Task" when child issue is created and linked with parent issue.

![automation rule-linked issues.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/342604i116F804DC83375D5/image-size/large?v=v2&px=999 "automation rule-linked issues.PNG")

Please Advise.

Thanks,

Venkatesh

Project

Project


Tags: data-center

jira-data-center