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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update fixVersion field on transaction

I have project with kanban board. When I release issue fixVersion field is updated.

But when i reopen released issue fixVersion field doesn't change so i don't see this issue on the board.

What is best way to update fixVersion field when transition happens? If it is no built-in way I have ScriptRunner on my Jira instance so could use it.

1 answer

1 accepted

0 votes
Answer accepted
Leo Community Leader Dec 13, 2019

Hi @Andrey Glazkov,

You can use below script for updating fix version field in post-function

import com.atlassian.jira.component.ComponentAccessor

def versionManager = ComponentAccessor.getVersionManager()
def project = issue.getProjectObject()
def version = versionManager.getVersion(project.getId(), "version name")

if (version) {
issue.setFixVersions([version])
log.warn("${issue.key} - fix version/s has been updated with ${version}")
}
else{
log.warn("Version does not available")
}

 

BR,

Leo

Hello, Leo and thanks for response!

Apparently I expressed myself inaccurately. I needed to clean up fixVersion field when issue moved from Closed status to any other statuses.

Your solution is correct but too complex for my case. After some investigation I googled apropriate solution:

In Post-Function menu select "Script Post-Function [ScriptRunner]" then select "Custom script post-function".

Use this script for post-function:

import com.atlassian.jira.issue.MutableIssue; 
MutableIssue issue = issue;
issue.setFixVersions(null);

 

Leo Community Leader Dec 16, 2019

hey, I thought you wanted to change fix version. but if you want to remove fix version/s value is quite easy and simple. just single line code is enough

issue.setFixVersions([])
log.warn("${issue.key} - fix version/s has been updated")

 

BR,

Leo

Like Andrey Glazkov likes this

Hi @Leo !

I tried 

issue.setFixVersions([])

in our environment (Jira 8.8.1, SR6.0.1-p5) and get the following error: 

image.png

Has there been a change in the API affecting how to clear FixVersions for an issue?

BR/Jonas

Leo Community Leader Jun 24, 2020

@Jonas Frid

my environment is 8.5.3 with 6.1.0 but no error

maybe you can give a try with below code

issue.setFixVersions(null)

 

BR,

Leo

@Leo 

Finally found that 6.0.1 suffered from:

SRJIRA-4308 - The type of issue in post-function was incorrectly Issue and not MutableIssue.

This was solved in 6.1.0.

(The code you suggested was my original code version where I discovered the error mesage ... so it was of course a good and valid suggestion ;-) )

 

BR/Jonas

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,549 views 22 32
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you