The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Lookup group members using variable

Deleted user
November 22, 2019

Hi,

I need to lookup users in jira groups depending on value in a custom field "Site". I have tried to write the below function, which works if I write in the actual group name, shown below. What I need is an if statement (or similar) that sets a group name to the variable "group", which is then returned by the function.

Can this be achieved? Can similar behaviour be achieved with different technique?

Thanks

def lookupGroupMembers(String s){
/*
Parameter s = site
retVal = List of users
*/
def group = "None"
if ( s == "Site1" ){ group = "made-up-Jira-group"}

/* This works - using group name*/
def groupManager = ComponentAccessor.getGroupManager()
def retVal = groupManager.getUsersInGroup("made-up-jira-group")

/* This does not work - using group variable */
def groupManager = ComponentAccessor.getGroupManager()
def retVal = groupManager.getUsersInGroup("group")

return retVal
}

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Jack Nolddor [Sweet Bananas]
Atlassian Partner
November 22, 2019

You need to change line:

def retVal = groupManager.getUsersInGroup("group")

.. and use the variable instead..

def retVal = groupManager.getUsersInGroup(group)

 

Regards

Deleted user
November 22, 2019

Thanks! Worked like a charm :)

TAGS
AUG Leaders

Atlassian Community Events