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

0 votes

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
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

421 views 7 5
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