I used the following to set the FixVersion based on the ScriptRunner documentation available here:
https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html
import com.atlassian.jira.component.ComponentAccessor
def versionManager = ComponentAccessor.getVersionManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def project = issue.getProjectObject()
def targetVersion = "FixVersionNameHere"
def version = versionManager.getVersion(project.getId(), targetVersion.toString())
issue.setFixVersions([version])
It worked when placed before the Create Issue event (commit to the database), as expected. I see in the ScriptRunner docs that it says "If you need your function to run after that, you have to use a more complex method."
Any ideas what that "more complex method" looks like?
ScriptRunner version 5.6.2