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

0 votes
Answer accepted
Jack Nolddor _Sweet Bananas_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
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 :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events