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
Where you've used user.name, you probably need user.getUsername() (or possibly user.getDisplayName(), but I think it's the login you want, not the display name)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.