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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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
Community Members
Community Events
Community Groups

How To Store History of FixVersion in Field


I am wanting to add a script to Jira to store the changes to the FixVersion field.  I've created a new field, PreviousFixVersion, to store the list of versions.  This field is the same type as the FixVersion field.  I can't seem to find a method to let me set the values.  

I've tried the following script in ScriptRunner:

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// Get the custom field objects for FixVersion and PreviousFixVersion
def fixVersionField = customFieldManager.getCustomFieldObjectsByName("Fix Version").first()
def previousFixVersionField = customFieldManager.getCustomFieldObjectsByName("PreviousFixVersion").first()

// Get the current issue and its current and previous FixVersion values
def currentFixVersions = issue.getCustomFieldValue(fixVersionField)
def previousFixVersions = issue.getCustomFieldValue(previousFixVersionField) ?: new ArrayList()

// Get the previous FixVersion value before the update
def changeLog = issue.changelog
if (changeLog) {
def changedValue = changeLog.getRelated("ChildChangeItem")?.find {it.field == "Fix Version"}

if (changedValue && changedValue.oldstring) {
def versionManager = ComponentAccessor.getVersionManager()
def previousVersion = versionManager.getVersion(, changedValue.oldstring)

// Add the previous FixVersion value to PreviousFixVersion field if not already present
if (previousVersion && !previousFixVersions.contains(previousVersion)) {
issue.setCustomFieldValue(previousFixVersionField, previousFixVersions)
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false)

However the issue.setCustomFieldValue call doesn't work.  

I am using Jira on-premise version 8.20.17. I also have Automation for Jira and ScriptRunner installed.

0 answers

Suggest an answer

Log in or Sign up to answer