Hi all,
I need to solve an issue, where I 'd like to have a single choice select list custom field with values (user names and user ID's) where the chosen option would be parsed based on user name or ID, validated against user management from crowd/LDAP), and the result (user) would populate a single choice user picker custom field, which can be later used e.g. for a validation on a transition.
Use case: Employee picks an "approver" from a list of people (single choice select list). This option is parsed, validated and matched to an actual JIRA user. This parsed JIRA user (e.g. approver), is then copied into another custom field (single choice user picker).
There are three scenarios:
1: Usage of an post function on any transition (or create screen) screen with the single choice custom field.
2: Using a Listener for a issue field update, when the single choice select list changes the value, then the approver changes as well.
3: Scenario 1 and 2 combined. That the single choice custom field can be changed on edit screen, but can be used on a transition screen as well (based on demand of the management or project/process owner)
Idea behind this request: I don't want people to start typing any name in a user picker field, but I want them to have all the possible "approvers" visible, listed in one select list.
Has anyone of you experience with something like this? Anyone who could advice me if I have to use a listener or it can be done in any other way?
Hello,
Try like this:
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUsers
def userManager = ComponentAccessor.getUserManager()
def groupManager = ComponentAccessor.getGroupManager()
def userDirectory = event.user.getDirectoryId()
log.warn(userDirectory)
log.warn(event.user)
def user = event.user
log.warn(user)
if (userDirectory==1) {
def group = groupManager.getGroup("CustomersExternal")
log.warn(group)
groupManager.addUserToGroup(ApplicationUsers.from(user),group)
}
That worked! Strangely, the script window was giving me an error but when it ran through the listener, no problems.
Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.