I'm trying to assign a newly created sub-task to a user group member via a post function that's supposed to trigger the sub-task creation.
I'm using the "Create a sub-task" post function from ScriptRunner.
The problem is that the assignee that I set in the script doesn't get applied to the created sub-task. It, instead, gets assigned to the project lead - the default assignee.
Here is the script:
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def groupManager = ComponentAccessor.getGroupManager()
def group = "TS Lead"
def user = groupManager.getUsersInGroup(group)?.get(0).getKey()
log.debug "user: "+user
if (! user) {
log.warn ("Could not retrieve user from the "+group+" role")
return
}
issue.assigneeId = user
According to multiple sources on this Q&A forum,
issue.assigneeId = user
is the correct way to set the assignee. This makes the problem even more confusing.
I also tried moving the post function to the top and bottom of the post function queue for the transition, but it didn't make a difference.
I've printed to log the issue and assignee at the end of the script, and the values appear correct. This leads me to believe that the issue or its fields aren't being saved.
I've used a similar script in a post function to assign a user group user to the current issue, rather than a new issue, and that worked fine.
I'm using JIRA 7.1.9 and ScriptRunner is version 5.1.6.
Any ideas on how to solve this?