Forums

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

Copying a custom field value to a second custom field at workflow transition

mark.barringer June 21, 2018

Hi,

I'm looking to copy values between custom fields, mainly at Issue Create but it could be at any workflow transition.

I can see suggestions how to do this using scriptrunner and add-ons.

Is there another way to achieve this without add-ons?

Many thanks

Mark

 

4 answers

1 vote
Mark Markov
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.
June 21, 2018

Hello @mark.barringer

Its easy to do with scriptrunner, you can use Script postfunction or Script LIsteners on Issue Created, Issue Updated event (which means every time issue created or updated, listeners catch that issue and perform coded actions)

Here example code. for listeners or workflow transitions

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


def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customField1 = customFieldManager.getCustomFieldObjectByName("customfield1name")
def customField2 = customFieldManager.getCustomFieldObjectByName("customfield2name")
//for workflow transitions
issue.setCustomFieldValue(customField2, issue.getCustomFieldValue(customField1))
// for listeners
((MutableIssue) event.issue).setCustomFieldValue(customField2, issue.getCustomFieldValue(customField1))
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

Jack Brickey
Community Champion
June 21, 2018

Mark, I'm confused why this cannot be done by a simple post function? Maybe I missed the question?

copy field.jpg

mark.barringer June 21, 2018

Hi, 

thanks for the answers. interesting I don't have that option. i'm using jira service desk server - no addons.

Postfunctions.PNG

0 votes
Payne
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.
June 21, 2018
mark.barringer June 21, 2018

thank you - I'll try this

0 votes
Mark Markov
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.
June 21, 2018

Outofthebox?

Jira v7.8

Screenshot_20180621-173226_Chrome.jpg

0 votes
Jack Brickey
Community Champion
June 21, 2018

Sure. You simply add a post function to your WF transition to copy the field.

Jack Brickey
Community Champion
June 21, 2018

Mea culpa....cloud has it but i'm guessing server does not. :-(

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events