Missed Team ’24? Catch up on announcements here.

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

Copy Value From Field to Field Function

ArulAnthonySebastian Nadar December 11, 2015

Hello Team,

Copy Value From Field to Field Function

A workflow function that copies the value(s) of a field to another field of the same issue.

Is it possible to merge custom field values and constant. (instead of replacing them with only the custom field).?

 

Regards,

Arul

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
December 11, 2015

You can also do this with the Update issues post function from Update on Transition for JIRA. You can construct the text string with constants and Substitution variables.

0 votes
Vasiliy Zverev
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.
December 11, 2015

Try this code for ScriptRunner

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.issue.fields.CustomField

/**
 * Script for copy value from one custom field to another
 */

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

CustomField cstFld_From = customFieldManager.getCustomFieldObjectByName("Name");
CustomField cstFld_To = customFieldManager.getCustomFieldObjectByName("Name");

if(     (cstFld_From == null)  
    &&  (cstFld_To == null) 
    &&  (cstFld_From.getCustomFieldType() != cstFld_To.getCustomFieldType()
    &&  (cstFld_From != cstFld_To)
    )) {
		//Prepare to update
UpdateIssueRequest.UpdateIssueRequestBuilder issueRequestBuilder = new 				UpdateIssueRequest.UpdateIssueRequestBuilder();
issueRequestBuilder.eventDispatchOption(EventDispatchOption.ISSUE_UPDATED);
issueRequestBuilder.sendMail(false);
UpdateIssueRequest updIssReq = new UpdateIssueRequest(issueRequestBuilder);        
issue.setCustomFieldValue(cstFld_To, cstFld_From.getValue(issue))
        			  issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getUser(), issue, updIssReq);
}
TAGS
AUG Leaders

Atlassian Community Events