I want to automatically assign a specific user (by using its username) based on the user group of the person creating the issue.
Therefore, I set up the following script by using Scriptrunner postfunction.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.util.UserManager
UserManager userManager = ComponentAccessor.getUserManager()
GroupManager groupManager = ComponentAccessor.getGroupManager()
def reporter = issue.getReporter()
if (groupManager.isUserInGroup(reporter, "AB01"))
{issue.setAssigneeId("U123456")}
else if (groupManager.isUserInGroup(reporter, "AB03"))
{issue.setAssigneeId("U654321")}
The purpose of this script is to assign the user "U123456" if the reporter is part of the user group "AB01" and to assign the user "U654321" if the reporter is part of the user group "AB03".
The users are well assigned to the issues in function of the user group but the problem is that they are not "recognized" as such in JIRA Service Desk although it's well their username. It acts as the assignee is empty even-though there is "U123456" or "U654321" in the field.
Did I do something wrong in my script ?
Thank you in advance for your help