Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,993
Community Members
 
Community Events
168
Community Groups

copy field value from one field to another within same issue

Hi All,

We have a requirement to copy field value from Summary to Ticket Summary (Text field) and Description to Ticket Description (Text Field ) .

Can some one help with the listner script to achive.

your inputs are highly appreciated.

 

Thank you,

Varun

1 answer

1 accepted

0 votes
Answer accepted

Hi @Varun Joseph Allu

For your requirement, you can try something like this:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

def issue = event.issue as MutableIssue

def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def sampleTextField = customFieldManager.getCustomFieldObjectsByName('Sample Text Field').first()
def sampleMultiLineText = customFieldManager.getCustomFieldObjectsByName('Sample Multi Line Text').first()

def description = issue.description
def summary = issue.summary

if (summary && description) {
issue.setCustomFieldValue(sampleTextField, summary)
issue.setCustomFieldValue(sampleMultiLineText, description)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}

Please note that the sample code provided is not 100% exact to your environment. Hence,  you will need to make the required modifications.

Below is a screenshot of the Listener Configuration:-

 listener_config.png

Below are a few test screenshots for your reference:-

1. First, when creating a new issue, only the values for the Summary and Description fields are entered.

test1.png

2. Once the issue has been created, as expected, the values from the Summary and Description fields are copied to the Sample Text Field and Sample Multi Line Text field accordingly, as shown in the screenshot below:-

test2.png

3. If the Summary field is updated, the Sample Text Field is updated accordingly, as shown in the screenshots below:-

test3.pngtest4.png

4. Similarly, if the Description field is updated, the Sample Multi Line Text field is updated accordingly, as shown below:-

test5.png

 

I hope this helps to solve your question. :)

 

Thank you and Kind regards,

Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_  ,

 

Thanks for the script,
It is working as expected.
Thank a lot for your support.

 

Regards,
Varun

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.21
TAGS

Atlassian Community Events