New Script Runner

Staros Nikos September 28, 2016

Hi , I would like to return all groups which have been assigned to a specific user in jira. Could anyone help me ? 

1 answer

0 votes
Thanos Batagiannis _Adaptavist_
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 Leaders.
September 28, 2016

Hi 

It depends on the context (is it for a listener, workflow function, etc), but in general try this in a script console

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
def userName = "admin"
def groupsForUser = groupManager.getGroupsForUser(userName) // a Collection <Group>
def groupsForUserString = groupManager.getGroupsForUser(userName)?.collect {it.name}?.join(", ") //a comma separated String representation of the collection
log.debug "Groups for user ${groupsForUserString}"

regards, Thanos

Suggest an answer

Log in or Sign up to answer