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

Tomas Arguinzones Yahoo November 10, 2017

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

1 vote
Joshua Yamdogo @ 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.
November 14, 2017

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