Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy summary from linked issue(parent issue) to custom field of child issue when child Issue created

Venkatesh Pettem August 18, 2024

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

2 answers

0 votes
John Price
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.
August 20, 2024

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

 

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

Venkatesh Pettem August 20, 2024 edited

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

John Price
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.
August 21, 2024

Hi @Venkatesh Pettem - 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!

0 votes
John Price
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.
August 19, 2024

Hey @Venkatesh Pettem -

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.

 

Venkatesh Pettem August 19, 2024 edited

Hi @John Price,

 

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

Please Advise.

Thanks,

Venkatesh

 

Project

 

Project

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira service management, jsm webinar, ai in jsm, opsgenie integration, incident management, virtual agent, atlassian intelligence, ai-powered service desk, it operations, atlassian learning, service management webinar, team '25 recap

What’s new in Jira Service Management 🤔

Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.

Register here ⬇️
AUG Leaders

Atlassian Community Events