How to copy field values between two custom fields without changing updated date?

Bartek Zukowski July 6, 2017

Hello,

Is it possible to copy custom field values without changing the updated date? I know that there is a buil-in script in Script Runner that does it but it doesn't allow to copy values from single select list into text field. And I need just that.

I wanted to use pretty simple script for copying values:

issues.each {
    def cf1 = cfm.getCustomFieldObject('customfield_12187').getValue(it).toString()
    def cf2 = cfm.getCustomFieldObject('customfield_11704')
    it.setCustomFieldValue(cf2,cf1)
    issueManager.updateIssue(user, it, EventDispatchOption.DO_NOT_DISPATCH, false)
}

But it changes Updated Date in each issue and that is very unwelcome for setting in 10k issues that I need to update.

Any ideas how to do it without messing with the database?

Regards,

Bartek

1 answer

0 votes
Daniel Yelamos [Adaptavist]
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.
July 10, 2017

Hello Bartek.

Before recommending you anything, I would advise you create a test project in which to test the two methods I'm about to recommend, so that you don't break anything in case I'm wrong :D

I have asked a senior in my team, and they've recommended you use com.atlassian.jira.issue.IssueManager#updateIssue with the eventDispatcher off. That should not trigger an event, and hence, it shouldn't update the date.

Also, you could test in one testing project the BulkFixResolutions canned script. It shouldn't update the date, but I cannot be 100% sure. Give it a test and let me know if it helped.

Cheers!

DYelamos

Bartek Zukowski July 11, 2017

Hi Daniel,

As you might see in my question I've used method you metioned and I've already tested it and it doesn't work like that. Indeed it doesn't fire an event but nevertheless it changes the Updated Date. 

And yeah, your built-in scripts can update issues without changing Updated Date but any of the built-in scripts can copy custom field values from single select to text field.

So, still looking for a solution...

Suggest an answer

Log in or Sign up to answer