updating Fix Version/s field via script listener in script runner

Hi all...I am having an issue updating the Fix Version/s field via a listener in script runner. For some reason the line that actually set the Fix Version/s field is not executing, so the the Fix Version/s field is not being updated. I am getting the correct string for the version I want to update the Fix Version/s field to and the version is indeed defined as a version for the project, but still the field is not being updated. This line seems to be doing what is expected to do, which is actually to update the Fix Version/s field:

issue.setFixVersions([versionFX])

 

I have tried a couple of suggestions from two of the techies from Adaptavist but none worked.

Thank you for your assistance!

Here is the complete script:

 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.project.version.VersionManager

 


def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Target Release"}
if (change) {

def customFieldManager = ComponentAccessor.getCustomFieldManager()
VersionManager versionManager = ComponentAccessor.versionManager
Issue issue = event.issue
def key=issue.getKey()

Object plugin = ComponentAccessor.getPluginAccessor().getPlugin("com.valiantys.jira.plugins.SQLFeed");
Class serviceClass = plugin.getClassLoader().loadClass("com.valiantys.nfeed.api.IFieldDisplayService");
ComponentManager componentManager = ComponentManager.getInstance();
Object fieldDisplayService = componentManager.getOSGiComponentInstanceOfType(serviceClass);
Object displayResult = fieldDisplayService.getDisplayResult(key, "customfield_12100");
String display = ""
display = displayResult.getDisplay();
log.warn("display: " + display)
Project project = issue.getProjectObject()
Version versionFX = versionManager.getVersion(project.getId(), display as String)
log.warn("versionFX: " + versionFX)
//def versions = issue.getFixVersions()
//log.warn("current versions: " + versions)
//versions.add(versionFX)
//log.warn("appended versions: " + versions)
issue.setFixVersions([versionFX])

}else
log.warn("no change of Target Release")
return

 

 

1 answer

This widget could not be displayed.

Hi Tomas,

I believe @Ashraful Hasan [Adaptavist] answered your question through our support portal. You no longer need help with this, correct? Feel free to post the script here if you'd like to share it with others. :)

Regards,

Josh

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

87 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you