Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing username from single choice select list

Deleted user
January 29, 2019

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?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 14, 2018

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)
}

Anthony Delgado
August 14, 2018

That worked!  Strangely, the script window was giving me an error but when it ran through the listener, no problems.

Thank you very much!

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 14, 2018

You are welcome!

TAGS
AUG Leaders

Atlassian Community Events