Hello all,
I want to set a custom field of type "single select"'s value on the event of a user being assigned, and by determining the user's group membership.
Say user A belongs to group "Product Management". Upon someone assigning an issue to him, I want to set custom field B (single select) to the existing option "Product Management".
As a first step I've succeeded doing this with a ScriptRunner custom field of type Script Field containing following code:
import com.atlassian.jira.component.ComponentAccessor
def user = issue.assignee
if (user) {
def userUtil = ComponentAccessor.getUserUtil()
if (userUtil.getGroupNamesForUser(user.name).contains("PM")) {
return "TEST Product Management"
} else {
return "Error - User not in defined group"
}
} else {
return ""
}
It successfully returns the group name as a string.
But now I want, but I am failing, to translate the same into something that makes use of the existing custom field of type single select, where there is no obvious way to apply a script.
I've read about the behaviour plugin and listeners and tried behaviours but getting specific errors on using userUtil.getGroupNamesForUser(user.name).contains("PM") in the inline script.
Can anyone please point me in the right direction, or provide some snippet to set respective values?
Thank you!
David